app background

test-errcode
wangchuxiao 2 years ago
parent 4c9859a1ac
commit ab176b5b1d

@ -9,7 +9,7 @@ import (
"time" "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} callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackUserOnline.Enable { if !config.Config.Callback.CallbackUserOnline.Enable {
return callbackResp return callbackResp
@ -25,9 +25,9 @@ func callbackUserOnline(operationID, userID string, platformID int, token string
}, },
UserID: userID, UserID: userID,
}, },
Seq: int(time.Now().UnixNano() / 1e6), Seq: int(time.Now().UnixNano() / 1e6),
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged, IsAppBackground: isAppBackground,
ConnID: connID, ConnID: connID,
} }
callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp} callbackUserOnlineResp := &cbApi.CallbackUserOnlineResp{CommonCallbackResp: &callbackResp}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOnlineCommand, callbackUserOnlineReq, callbackUserOnlineResp, config.Config.Callback.CallbackUserOnline.CallbackTimeOut); err != nil { 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 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} callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackUserOffline.Enable { if !config.Config.Callback.CallbackUserOffline.Enable {
return callbackResp return callbackResp
@ -52,9 +52,8 @@ func callbackUserOffline(operationID, userID string, platformID int, isAppBackgr
}, },
UserID: userID, UserID: userID,
}, },
Seq: int(time.Now().UnixNano() / 1e6), Seq: int(time.Now().UnixNano() / 1e6),
IsAppBackgroundStatusChanged: isAppBackgroundStatusChanged, ConnID: connID,
ConnID: connID,
} }
callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp} callbackUserOfflineResp := &cbApi.CallbackUserOfflineResp{CommonCallbackResp: &callbackResp}
if err := http.CallBackPostReturn(config.Config.Callback.CallbackUrl, constant.CallbackUserOfflineCommand, callbackOfflineReq, callbackUserOfflineResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil { 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 { if isPass {
req := pData.(*sdk_ws.SetAppBackgroundStatusReq) req := pData.(*sdk_ws.SetAppBackgroundStatusReq)
conn.IsBackground = req.IsBackground conn.IsBackground = req.IsBackground
if !conn.IsBackground { callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, conn.IsBackground, conn.connID)
callbackResp := callbackUserOnline(m.OperationID, conn.userID, int(conn.PlatformID), conn.token, true, conn.connID) if callbackResp.ErrCode != 0 {
if callbackResp.ErrCode != 0 { log.NewError(m.OperationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
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)
}
} }
log.NewInfo(m.OperationID, "SetUserDeviceBackground", "success", *conn, req.IsBackground) log.NewInfo(m.OperationID, "SetUserDeviceBackground", "success", *conn, req.IsBackground)
} }
ws.setUserDeviceBackgroundResp(conn, m, errCode, errMsg) ws.setUserDeviceBackgroundResp(conn, m, errCode, errMsg)

@ -388,7 +388,7 @@ func (ws *WServer) delUserConn(conn *UserConn) {
if err != nil { if err != nil {
log.Error(operationID, " close err", "", "uid", uid, "platform", platform) 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 { if callbackResp.ErrCode != 0 {
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp) log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
} }

@ -2,10 +2,10 @@ package call_back_struct
type CallbackUserOnlineReq struct { type CallbackUserOnlineReq struct {
UserStatusCallbackReq UserStatusCallbackReq
Token string `json:"token"` Token string `json:"token"`
Seq int `json:"seq"` Seq int `json:"seq"`
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"` IsAppBackground bool `json:"isAppBackground"`
ConnID string `json:"connID"` ConnID string `json:"connID"`
} }
type CallbackUserOnlineResp struct { type CallbackUserOnlineResp struct {
@ -14,9 +14,8 @@ type CallbackUserOnlineResp struct {
type CallbackUserOfflineReq struct { type CallbackUserOfflineReq struct {
UserStatusCallbackReq UserStatusCallbackReq
Seq int `json:"seq"` Seq int `json:"seq"`
IsAppBackgroundStatusChanged bool `json:"isAppBackgroundStatusChanged"` ConnID string `json:"connID"`
ConnID string `json:"connID"`
} }
type CallbackUserOfflineResp struct { type CallbackUserOfflineResp struct {

Loading…
Cancel
Save