This commit is contained in:
邹宗楠
2022-10-22 22:44:39 +08:00
parent 04f1190953
commit 5a47102894
37 changed files with 4 additions and 115 deletions

View File

@@ -172,7 +172,6 @@ func (c *EventController) TestWebsocket() {
//接收客户端的消息
err := ws.ReadJSON(&s)
if err != nil {
globals.SugarLogger.Debugf("页面可能断开啦 ws.ReadJSON error: %v", err.Error())
index := 0
for k, v := range clients[vendorOrderID] {
if v == ws {
@@ -205,15 +204,12 @@ func handleMessages() {
for {
//读取通道中的消息
msg := <-broadcast
globals.SugarLogger.Debugf("clients len %v", len(clients))
//循环map客户端
for vendorOrderID, mmsg := range msg {
for _, client := range clients[vendorOrderID] {
//把通道中的消息发送给客户端
globals.SugarLogger.Debugf("msg %v", utils.Format4Output(mmsg, false))
err := client.WriteJSON(mmsg)
if err != nil {
globals.SugarLogger.Debugf("client.WriteJSON error: %v", err)
client.Close() //关闭
index := 0
for k, v := range clients[vendorOrderID] {