mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-08-30 02:30:01 +08:00
app background
This commit is contained in:
parent
4c9859a1ac
commit
ab176b5b1d
@ -9,7 +9,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackgroundStatusChanged bool, connID string) cbApi.CommonCallbackResp {
|
||||
func callbackUserOnline(operationID, userID string, platformID int, token string, isAppBackground bool, connID string) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackUserOnline.Enable {
|
||||
return callbackResp
|
||||
@ -25,9 +25,9 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
|
||||
},
|
||||
UserID: userID,
|
||||
},
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged,
|
||||
ConnID: connID,
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
IsAppBackground: isAppBackground,
|
||||
ConnID: connID,
|
||||
}
|
||||
callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil {
|
||||
@ -37,7 +37,7 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
|
||||
return callbackResp
|
||||
}
|
||||
|
||||
func callbackUserOffline(operationID, userID string, platformID int, isAppBackgroundStatusChanged bool, connID string) cbApi.CommonCallbackResp {
|
||||
func callbackUserOffline(operationID, userID string, platformID int, connID string) cbApi.CommonCallbackResp {
|
||||
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
|
||||
if !config.Config.Callback.CallbackUserOffline.Enable {
|
||||
return callbackResp
|
||||
@ -52,9 +52,8 @@ func callbackUserOffline(operationID, userID string, platformID int, isAppBackgr
|
||||
},
|
||||
UserID: userID,
|
||||
},
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged,
|
||||
ConnID: connID,
|
||||
Seq: int(time.Now().UnixNano() / 1e6),
|
||||
ConnID: connID,
|
||||
}
|
||||
callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp}
|
||||
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
|
||||
|
@ -406,18 +406,10 @@ func (ws *WServer) setUserDeviceBackground(conn *UserConn, m *Req) {
|
||||
if isPass {
|
||||
req := pData.(*sdk_ws.SetAppBackgroundStatusReq)
|
||||
conn.IsBackground = req.IsBackground
|
||||
if !conn.IsBackground {
|
||||
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, true, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
||||
}
|
||||
} else {
|
||||
callbackResp := callbackUserOffline(m.OperationID, conn.userID, int(conn.PlatformID), true, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
||||
}
|
||||
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, conn.IsBackground, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
||||
}
|
||||
|
||||
log.NewInfo(m.OperationID, "SetUserDeviceBackground", "success", *conn, req.IsBackground)
|
||||
}
|
||||
ws.setUserDeviceBackgroundResp(conn, m, errCode, errMsg)
|
||||
|
@ -388,7 +388,7 @@ func (ws *WServer) delUserConn(conn *UserConn) {
|
||||
if err != nil {
|
||||
log.Error(operationID, " close err", "", "uid", uid, "platform", platform)
|
||||
}
|
||||
callbackResp := callbackUserOffline(operationID, conn.userID, platform, false, conn.connID)
|
||||
callbackResp := callbackUserOffline(operationID, conn.userID, platform, conn.connID)
|
||||
if callbackResp.ErrCode != 0 {
|
||||
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package call_back_struct
|
||||
|
||||
type CallbackUserOnlineReq struct {
|
||||
UserStatusCallbackReq
|
||||
Token string `json:"token"`
|
||||
Seq int `json:"seq"`
|
||||
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"`
|
||||
ConnID string `json:"connID"`
|
||||
Token string `json:"token"`
|
||||
Seq int `json:"seq"`
|
||||
IsAppBackground bool `json:"isAppBackground"`
|
||||
ConnID string `json:"connID"`
|
||||
}
|
||||
|
||||
type CallbackUserOnlineResp struct {
|
||||
@ -14,9 +14,8 @@ type CallbackUserOnlineResp struct {
|
||||
|
||||
type CallbackUserOfflineReq struct {
|
||||
UserStatusCallbackReq
|
||||
Seq int `json:"seq"`
|
||||
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"`
|
||||
ConnID string `json:"connID"`
|
||||
Seq int `json:"seq"`
|
||||
ConnID string `json:"connID"`
|
||||
}
|
||||
|
||||
type CallbackUserOfflineResp struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user