This commit is contained in:
laodaming 2023-08-24 15:59:55 +08:00
parent 991f3c5cd5
commit 190010a6fe
3 changed files with 6 additions and 9 deletions

View File

@ -31,15 +31,12 @@ func NewCommonNotifyLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Comm
// }
func (l *CommonNotifyLogic) CommonNotify(req *types.CommonNotifyReq, userinfo *auth.UserInfo) (resp *basic.Response) {
if req.Data == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "data is empty")
}
//websocket连接id不能为空
if req.WebsocketId == "" {
if req.Wid == "" {
return resp.SetStatusWithMessage(basic.CodeRequestParamsErr, "websocket connect id is empty")
}
//查询websocket连接
value, ok := mapConnPool.Load(req.WebsocketId)
value, ok := mapConnPool.Load(req.Wid)
if !ok {
return resp.SetStatusWithMessage(basic.CodeOK, "success,but connection is not found")
}

View File

@ -13,8 +13,8 @@ type RenderNotifyReq struct {
}
type CommonNotifyReq struct {
WebsocketId string `json:"websocket_id"` //websocket连接标识
Data map[string]interface{} `json:"data"` //后端与前端约定好的数据
Wid string `json:"wid"` //websocket连接标识
Data map[string]interface{} `json:"data"` //后端与前端约定好的数据
}
type Request struct {

View File

@ -29,6 +29,6 @@ type RenderNotifyReq {
}
//通用回调接口
type CommonNotifyReq {
WebsocketId string `json:"websocket_id"` //websocket连接标识
Data map[string]interface{} `json:"data"` //后端与前端约定好的数据
Wid string `json:"wid"` //websocket连接标识
Data map[string]interface{} `json:"data"` //后端与前端约定好的数据
}