multimedia/server/webrtc_easy_signal/callbacks.go

58 lines
910 B
Go

/*
* @Author: your name
* @Date: 2021-10-21 22:36:25
* @LastEditTime: 2021-10-21 23:01:28
* @LastEditors: Please set LastEditors
* @Description: In User Settings Edit
* @FilePath: \webrtc_easy_signal\proto.go
*/
package main
import (
"encoding/json"
"log"
"sync"
)
type Request struct{
Type int `json:"type"`
Data map[string]interface{} `json:"data"`
}
const (
REQ_INROOM = 1001
REQ_LEAVEROOM = 1002
REQ_CREATEROOM = 1003
REQ_LISTROOM = 1004
REQ_SENDSDP = 1005
)
var gmap sync.Map
func ProtoCallBack(ws *WsConnection,dat []byte) {
if nil == ws{
return
}
var payload Request
e := json.Unmarshal(dat, &payload)
if nil != e {
log.Print(e.Error())
}
log.Print(payload)
switch(payload.Type){
case REQ_INROOM:
log.Print(payload.Data["message"])
break
case REQ_CREATEROOM:
break
case REQ_LEAVEROOM:
break
case REQ_LISTROOM:
break
case REQ_SENDSDP:
break
}
}