Skip to content

Commit cbd29a7

Browse files
authored
build: add sdk version log when registerClient (#3574)
1 parent ea6b7eb commit cbd29a7

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

internal/msggateway/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ type Client struct {
7070
UserID string `json:"userID"`
7171
IsBackground bool `json:"isBackground"`
7272
SDKType string `json:"sdkType"`
73+
SDKVersion string `json:"sdkVersion"`
7374
Encoder Encoder
7475
ctx *UserConnContext
7576
longConnServer LongConnServer
@@ -97,6 +98,7 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn LongConn, longConnServer
9798
c.closedErr = nil
9899
c.token = ctx.GetToken()
99100
c.SDKType = ctx.GetSDKType()
101+
c.SDKVersion = ctx.GetSDKVersion()
100102
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
101103
c.subLock = new(sync.Mutex)
102104
if c.subUserIDs != nil {

internal/msggateway/constant.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const (
2828
BackgroundStatus = "isBackground"
2929
SendResponse = "isMsgResp"
3030
SDKType = "sdkType"
31+
SDKVersion = "sdkVersion"
3132
)
3233

3334
const (

internal/msggateway/context.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
package msggateway
1616

1717
import (
18-
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
1918
"net/http"
2019
"net/url"
2120
"strconv"
2221
"time"
2322

23+
"github.com/openimsdk/open-im-server/v3/pkg/common/servererrs"
24+
2425
"github.com/openimsdk/protocol/constant"
2526
"github.com/openimsdk/tools/utils/encrypt"
2627
"github.com/openimsdk/tools/utils/stringutil"
@@ -140,6 +141,10 @@ func (c *UserConnContext) GetToken() string {
140141
return c.Req.URL.Query().Get(Token)
141142
}
142143

144+
func (c *UserConnContext) GetSDKVersion() string {
145+
return c.Req.URL.Query().Get(SDKVersion)
146+
}
147+
143148
func (c *UserConnContext) GetCompression() bool {
144149
compression, exists := c.Query(Compression)
145150
if exists && compression == GzipCompressionProtocol {

internal/msggateway/ws_server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ func (ws *WsServer) registerClient(client *Client) {
254254
oldClients []*Client
255255
)
256256
oldClients, userOK, clientOK = ws.clients.Get(client.UserID, client.PlatformID)
257+
258+
log.ZInfo(client.ctx, "registerClient", "userID", client.UserID, "platformID", client.PlatformID,
259+
"sdkVersion", client.SDKVersion)
260+
257261
if !userOK {
258262
ws.clients.Set(client.UserID, client)
259263
log.ZDebug(client.ctx, "user not exist", "userID", client.UserID, "platformID", client.PlatformID)

0 commit comments

Comments
 (0)