|
@@ -18,6 +18,7 @@ type Client struct {
|
|
|
UserId string
|
|
|
hub *Hub
|
|
|
UnderlyingConn *websocket.Conn
|
|
|
+ online *models.Online
|
|
|
|
|
|
isRemotely bool // isRemotely 是否是远程连接
|
|
|
isSimpleMsg bool // isSimpleMsg 是否是简单消息
|
|
@@ -49,6 +50,7 @@ func (c *Client) reader() {
|
|
|
zlog.Errorf("error: %v", err)
|
|
|
}
|
|
|
// Close connect
|
|
|
+ _ = c.repos.OnlineRepository.Offline(c.ctx, c.online)
|
|
|
break
|
|
|
}
|
|
|
|
|
@@ -56,8 +58,7 @@ func (c *Client) reader() {
|
|
|
switch message.Type {
|
|
|
case MessageTypePingPong:
|
|
|
zlog.Debugf("receive ping message from %s", c.UserId)
|
|
|
- o := &models.Online{UserId: c.UserId, ServerId: c.hub.serverId}
|
|
|
- _ = c.repos.OnlineRepository.Heartbeat(c.ctx, o)
|
|
|
+ _ = c.repos.OnlineRepository.Heartbeat(c.ctx, c.online)
|
|
|
case MessageTypeUpChating, MessageTypeDownChating:
|
|
|
// Chat dialogue messages
|
|
|
chatingContent := message.Content.(ChatingContent)
|