This commit is contained in:
richboo111
2023-05-05 14:48:54 +08:00
parent 2b7bfe4e5e
commit 82cd796b5c
11 changed files with 343 additions and 188 deletions

View File

@@ -11,46 +11,13 @@ type IMController struct {
web.Controller
}
var maxMessageSize = int64(8192) // 最大的消息大小
// @Title IM初始化长链接
// @Description IM初始化长链接
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /StartWebSocket [get]
func (c *IMController) StartWebSocket() {
im.Run(c.Ctx.ResponseWriter, c.Ctx.Request)
//
//upgrader.CheckOrigin = func(r *http.Request) bool {
// return true
//}
//conn, err := upgrader.Upgrade(c.Ctx.ResponseWriter, c.Ctx.Request, nil)
//if err != nil {
// globals.SugarLogger.Errorf("upgrade error: %v", err)
// return
//}
//defer conn.Close()
//
//clientID := c.GetString("clientID")
//globals.SugarLogger.Debugf("clientID=%s", clientID)
//
////设置读取消息大小上线
//conn.SetReadLimit(maxMessageSize)
//
//clientSocket := im.NewClient(clientID, conn)
//
////读取客户端消息
//clientSocket.Read()
//
//if err = im.ConnRender(conn, im.RetData{Data: clientID}); err != nil {
// _ = conn.Close()
// return
//}
//
//// 用户连接事件
//im.Manager.Connect <- clientSocket
}
// @Title IM获取门店用户聊天列表