refactor: replace LongConn with ClientConn interface and simplify message handling

This commit is contained in:
withchao
2025-12-19 15:53:17 +08:00
parent a1dd79a459
commit 9da7db2ac2
2 changed files with 13 additions and 0 deletions
+11
View File
@@ -38,6 +38,7 @@ type UserConnContextInfo struct {
SDKType string `json:"sdkType"`
SendResponse bool `json:"sendResponse"`
Background bool `json:"background"`
SDKVersion string `json:"sdkVersion"`
}
type UserConnContext struct {
@@ -74,6 +75,8 @@ func (c *UserConnContext) Value(key any) any {
return c.GetPlatformID()
case constant.RemoteAddr:
return c.RemoteAddr
case SDKVersion:
return c.info.SDKVersion
default:
return ""
}
@@ -117,6 +120,7 @@ func (c *UserConnContext) parseByQuery(query url.Values, header http.Header) err
OperationID: query.Get(OperationID),
Compression: query.Get(Compression),
SDKType: query.Get(SDKType),
SDKVersion: query.Get(SDKVersion),
}
platformID, err := strconv.Atoi(query.Get(PlatformID))
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 {
return c != nil && c.info != nil && c.info.SendResponse
}