fix
This commit is contained in:
parent
d0fc91b61b
commit
b0f598af68
|
@ -97,8 +97,8 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
mapConnPool.Store(flag, ws)
|
||||
defer ws.close()
|
||||
//把连接成功消息发回去
|
||||
rsp.MsgType = constants.WEBSOCKET_CONNECT_SUCCESS
|
||||
rsp.Message = flag
|
||||
rsp.T = constants.WEBSOCKET_CONNECT_SUCCESS
|
||||
rsp.D = flag
|
||||
b, _ := json.Marshal(rsp)
|
||||
conn.WriteMessage(websocket.TextMessage, b)
|
||||
//循环读客户端信息
|
||||
|
@ -116,8 +116,8 @@ func DataTransferHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
// 心跳
|
||||
func (w *wsConnectItem) heartbeat() {
|
||||
rsp := types.DataTransferRsp{
|
||||
MsgType: constants.WEBSOCKET_HEARTBEAT,
|
||||
Message: "",
|
||||
T: constants.WEBSOCKET_HEARTBEAT,
|
||||
D: "",
|
||||
}
|
||||
for {
|
||||
time.Sleep(time.Second * 10)
|
||||
|
@ -202,11 +202,11 @@ func (w *wsConnectItem) dealwithReciveData(data []byte) {
|
|||
logx.Error("invalid format of websocket message")
|
||||
return
|
||||
}
|
||||
switch parseInfo.MsgType {
|
||||
switch parseInfo.T {
|
||||
//图片渲染
|
||||
case constants.WEBSOCKET_RENDER_IMAGE:
|
||||
var renderImageData []types.RenderImageReqMsg
|
||||
if err := json.Unmarshal([]byte(parseInfo.Message), &renderImageData); err != nil {
|
||||
if err := json.Unmarshal([]byte(parseInfo.D), &renderImageData); err != nil {
|
||||
logx.Error("invalid format of websocket render image message", err)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ func RenderNotifyHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
h.Write([]byte(fmt.Sprintf(constants.RENDER_NOTIFY_SIGN_KEY, string(notifyByte), req.Time)))
|
||||
signHex := h.Sum(nil)
|
||||
sign := hex.EncodeToString(signHex)
|
||||
fmt.Println(sign)
|
||||
if req.Sign != sign {
|
||||
httpx.OkJsonCtx(r.Context(), w, basic.Response{
|
||||
Code: basic.CodeRequestParamsErr.Code,
|
||||
|
|
|
@ -6,13 +6,13 @@ import (
|
|||
)
|
||||
|
||||
type DataTransferReq struct {
|
||||
MsgType string `json:"msg_type"` //消息类型
|
||||
Message string `json:"message"` //传递的消息
|
||||
T string `json:"t"` //消息类型
|
||||
D string `json:"d"` //传递的消息
|
||||
}
|
||||
|
||||
type DataTransferRsp struct {
|
||||
MsgType string `json:"msg_type"` //消息类型
|
||||
Message string `json:"message"` //传递的消息
|
||||
T string `json:"t"` //消息类型
|
||||
D string `json:"d"` //传递的消息
|
||||
}
|
||||
|
||||
type RenderImageReqMsg struct {
|
||||
|
|
|
@ -19,12 +19,12 @@ service websocket {
|
|||
|
||||
//websocket数据交互
|
||||
type DataTransferReq {
|
||||
MsgType string `json:"msg_type"` //消息类型
|
||||
Message string `json:"message"` //传递的消息
|
||||
T string `json:"t"` //消息类型
|
||||
D string `json:"d"` //传递的消息
|
||||
}
|
||||
type DataTransferRsp {
|
||||
MsgType string `json:"msg_type"` //消息类型
|
||||
Message string `json:"message"` //传递的消息
|
||||
T string `json:"t"` //消息类型
|
||||
D string `json:"d"` //传递的消息
|
||||
}
|
||||
type RenderImageReqMsg { //websocket接受需要云渲染的图片
|
||||
ProductId int64 `json:"product_id"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user