mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-23 23:57:11 +08:00
Merge pull request #3644 from withchao/pre-release-v3.8.4
feat: replace LongConn with ClientConn interface and simplify message handling
This commit is contained in:
commit
3b921bfbdb
@ -68,6 +68,7 @@ type Client struct {
|
|||||||
UserID string `json:"userID"`
|
UserID string `json:"userID"`
|
||||||
IsBackground bool `json:"isBackground"`
|
IsBackground bool `json:"isBackground"`
|
||||||
SDKType string `json:"sdkType"`
|
SDKType string `json:"sdkType"`
|
||||||
|
SDKVersion string `json:"sdkVersion"`
|
||||||
Encoder Encoder
|
Encoder Encoder
|
||||||
ctx *UserConnContext
|
ctx *UserConnContext
|
||||||
longConnServer LongConnServer
|
longConnServer LongConnServer
|
||||||
@ -95,6 +96,7 @@ func (c *Client) ResetClient(ctx *UserConnContext, conn ClientConn, longConnServ
|
|||||||
c.closedErr = nil
|
c.closedErr = nil
|
||||||
c.token = ctx.GetToken()
|
c.token = ctx.GetToken()
|
||||||
c.SDKType = ctx.GetSDKType()
|
c.SDKType = ctx.GetSDKType()
|
||||||
|
c.SDKVersion = ctx.GetSDKVersion()
|
||||||
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
|
c.hbCtx, c.hbCancel = context.WithCancel(c.ctx)
|
||||||
c.subLock = new(sync.Mutex)
|
c.subLock = new(sync.Mutex)
|
||||||
if c.subUserIDs != nil {
|
if c.subUserIDs != nil {
|
||||||
|
|||||||
@ -38,6 +38,7 @@ type UserConnContextInfo struct {
|
|||||||
SDKType string `json:"sdkType"`
|
SDKType string `json:"sdkType"`
|
||||||
SendResponse bool `json:"sendResponse"`
|
SendResponse bool `json:"sendResponse"`
|
||||||
Background bool `json:"background"`
|
Background bool `json:"background"`
|
||||||
|
SDKVersion string `json:"sdkVersion"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserConnContext struct {
|
type UserConnContext struct {
|
||||||
@ -74,6 +75,8 @@ func (c *UserConnContext) Value(key any) any {
|
|||||||
return c.GetPlatformID()
|
return c.GetPlatformID()
|
||||||
case constant.RemoteAddr:
|
case constant.RemoteAddr:
|
||||||
return c.RemoteAddr
|
return c.RemoteAddr
|
||||||
|
case SDKVersion:
|
||||||
|
return c.info.SDKVersion
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
@ -117,6 +120,7 @@ func (c *UserConnContext) parseByQuery(query url.Values, header http.Header) err
|
|||||||
OperationID: query.Get(OperationID),
|
OperationID: query.Get(OperationID),
|
||||||
Compression: query.Get(Compression),
|
Compression: query.Get(Compression),
|
||||||
SDKType: query.Get(SDKType),
|
SDKType: query.Get(SDKType),
|
||||||
|
SDKVersion: query.Get(SDKVersion),
|
||||||
}
|
}
|
||||||
platformID, err := strconv.Atoi(query.Get(PlatformID))
|
platformID, err := strconv.Atoi(query.Get(PlatformID))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -246,6 +250,13 @@ func (c *UserConnContext) GetSDKType() string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *UserConnContext) GetSDKVersion() string {
|
||||||
|
if c == nil || c.info == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return c.info.SDKVersion
|
||||||
|
}
|
||||||
|
|
||||||
func (c *UserConnContext) ShouldSendResp() bool {
|
func (c *UserConnContext) ShouldSendResp() bool {
|
||||||
return c != nil && c.info != nil && c.info.SendResponse
|
return c != nil && c.info != nil && c.info.SendResponse
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user