Merge branch 'main' of http://192.168.2.166:3180/OMC/ems_backend
This commit is contained in:
@@ -85,7 +85,17 @@ func (s *WSImpl) NewClient(uid string, groupIDs []string, conn *websocket.Conn)
|
|||||||
for _, groupID := range groupIDs {
|
for _, groupID := range groupIDs {
|
||||||
if v, ok := WsGroup.Load(groupID); ok {
|
if v, ok := WsGroup.Load(groupID); ok {
|
||||||
groupUIDs := v.(*[]string)
|
groupUIDs := v.(*[]string)
|
||||||
|
// 避免同组内相同用户
|
||||||
|
hasUid := false
|
||||||
|
for _, uidv := range *groupUIDs {
|
||||||
|
if uidv == uid {
|
||||||
|
hasUid = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !hasUid {
|
||||||
*groupUIDs = append(*groupUIDs, uid)
|
*groupUIDs = append(*groupUIDs, uid)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
WsGroup.Store(groupID, &[]string{uid})
|
WsGroup.Store(groupID, &[]string{uid})
|
||||||
}
|
}
|
||||||
@@ -145,6 +155,7 @@ func (s *WSImpl) clientWrite(wsClient *model.WSClient) {
|
|||||||
s.CloseClient(wsClient.ID)
|
s.CloseClient(wsClient.ID)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
wsClient.LastHeartbeat = time.Now().UnixMilli()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ func (s *WSSendImpl) ByClientID(clientID string, data any) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
client := v.(*model.WSClient)
|
client := v.(*model.WSClient)
|
||||||
|
if len(client.MsgChan) > 90 {
|
||||||
|
NewWSImpl.CloseClient(client.ID)
|
||||||
|
return fmt.Errorf("msg chan over 90 will close client ID: %s", clientID)
|
||||||
|
}
|
||||||
client.MsgChan <- dataByte
|
client.MsgChan <- dataByte
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user