callback kickoff

pull/265/head
wangchuxiao 2 years ago
parent 06729c4e84
commit c4084cbcec

@ -299,6 +299,9 @@ callback:
callbackUserOffline:
enable: false
callbackTimeOut: 2
callbackUserKickOff:
enable: false
callbackTimeOut: 2
callbackOfflinePush:
enable: false
callbackTimeOut: 2

@ -59,3 +59,28 @@ func callbackUserOffline(operationID, userID string, platformID int) cbApi.Commo
}
return callbackResp
}
func callbackUserKickOff(operationID string, userID string, platformID int) cbApi.CommonCallbackResp {
callbackResp := cbApi.CommonCallbackResp{OperationID: operationID}
if !config.Config.Callback.CallbackUserKickOff.Enable {
return callbackResp
}
callbackUserKickOffReq := cbApi.CallbackUserKickOffReq{
UserStatusCallbackReq: cbApi.UserStatusCallbackReq{
UserStatusBaseCallback: cbApi.UserStatusBaseCallback{
CallbackCommand: constant.CallbackUserKickOffCommand,
OperationID: operationID,
PlatformID: int32(platformID),
Platform: constant.PlatformIDToName(platformID),
},
UserID: userID,
},
Seq: int(time.Now().UnixNano() / 1e6),
}
callbackUserKickOffResp := &cbApi.CallbackUserKickOffResp{CommonCallbackResp: callbackResp}
if err := http.PostReturn(config.Config.Callback.CallbackUrl, callbackUserKickOffReq, callbackUserKickOffResp, config.Config.Callback.CallbackUserOffline.CallbackTimeOut); err != nil {
callbackResp.ErrCode = http2.StatusInternalServerError
callbackResp.ErrMsg = err.Error()
}
return callbackResp
}

@ -233,6 +233,10 @@ func (ws *WServer) MultiTerminalLoginChecker(uid string, platformID int, newConn
if err != nil {
log.NewError(operationID, "conn close err", err.Error(), uid, platformID)
}
callbackResp := callbackUserKickOff(operationID, uid, platformID)
if callbackResp.ErrCode != 0 {
log.NewError(operationID, utils.GetSelfFuncName(), "callbackUserOffline failed", callbackResp)
}
} else {
log.NewWarn(operationID, "normal uid-conn ", uid, platformID, oldConnMap[platformID])
}

@ -18,3 +18,12 @@ type CallbackUserOfflineReq struct {
type CallbackUserOfflineResp struct {
CommonCallbackResp
}
type CallbackUserKickOffReq struct {
UserStatusCallbackReq
Seq int `json:"seq"`
}
type CallbackUserKickOffResp struct {
CommonCallbackResp
}

@ -264,6 +264,7 @@ type config struct {
CallbackWordFilter callBackConfig `yaml:"callbackWordFilter"`
CallbackUserOnline callBackConfig `yaml:"callbackUserOnline"`
CallbackUserOffline callBackConfig `yaml:"callbackUserOffline"`
CallbackUserKickOff callBackConfig `yaml:"callbackUserKickOff"`
CallbackOfflinePush callBackConfig `yaml:"callbackOfflinePush"`
CallbackOnlinePush callBackConfig `yaml:"callbackOnlinePush"`
CallbackBeforeSuperGroupOnlinePush callBackConfig `yaml:"callbackSuperGroupOnlinePush"`

@ -200,6 +200,7 @@ const (
CallbackWordFilterCommand = "callbackWordFilterCommand"
CallbackUserOnlineCommand = "callbackUserOnlineCommand"
CallbackUserOfflineCommand = "callbackUserOfflineCommand"
CallbackUserKickOffCommand = "callbackUserKickOffCommand"
CallbackOfflinePushCommand = "callbackOfflinePushCommand"
CallbackOnlinePushCommand = "callbackOnlinePushCommand"
CallbackSuperGroupOnlinePushCommand = "callbackSuperGroupOnlinePushCommand"

Loading…
Cancel
Save