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