fix: ws 消息格式统一
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user