fix: ws 消息格式统一

This commit is contained in:
TsMask
2024-01-24 14:10:23 +08:00
parent 0210d28cdb
commit 3135ff5b85
2 changed files with 22 additions and 12 deletions

View File

@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"ems.agt/src/framework/vo/result"
"ems.agt/src/modules/ws/model"
)
@@ -29,7 +30,7 @@ func (s *WSSendImpl) ByClientID(clientID string, data any) error {
return fmt.Errorf("no fount client ID: %s", clientID)
}
dataByte, err := json.Marshal(data)
dataByte, err := json.Marshal(result.OkData(data))
if err != nil {
return err
}
@@ -61,7 +62,10 @@ func (s *WSSendImpl) ByGroupID(groupID string, data any) error {
// 在用户中找到客户端并发送
uidClientIds := clientIds.(*[]string)
for _, clientId := range *uidClientIds {
err := s.ByClientID(clientId, data)
err := s.ByClientID(clientId, map[string]any{
"groupID": groupID,
"data": data,
})
if err != nil {
continue
}