This commit is contained in:
苏尹岚
2020-08-20 11:38:28 +08:00
parent 46d5ce5c02
commit dcdd41feaa

View File

@@ -132,13 +132,9 @@ func (c *EventController) TestWebsocket() {
//将当前客户端放入map中 //将当前客户端放入map中
clients[ws] = true clients[ws] = true
m := &model.ImMessageRecord{}
//把消息 写入通道
broadcast <- m
c.EnableRender = false //Beego不启用渲染 c.EnableRender = false //Beego不启用渲染
var s model.ImMessageRecord var s *model.ImMessageRecord
for { for {
//接收客户端的消息 //接收客户端的消息
err := ws.ReadJSON(&s) err := ws.ReadJSON(&s)
@@ -147,6 +143,8 @@ func (c *EventController) TestWebsocket() {
delete(clients, ws) //删除map中的客户端 delete(clients, ws) //删除map中的客户端
break //结束循环 break //结束循环
} else { } else {
//把消息 写入通道
broadcast <- s
//接受消息 业务逻辑 //接受消息 业务逻辑
db := dao.GetDB() db := dao.GetDB()
dao.WrapAddIDCULDEntity(&s, "") dao.WrapAddIDCULDEntity(&s, "")