Skip to main content

User Online Status Callback

Function Description

The App business server can use this callback to change the user's status to online.

Notes

  • To enable the callback, it is necessary to configure the callback URL and activate the switch corresponding to this callback protocol. For configuration methods, see the Callback Description document.
  • The direction of the callback is an HTTP/HTTPS POST request initiated by OpenIM Server to the App backend.
  • After receiving the callback request, the App business server needs to verify whether the command parameter in the request URL is their own SDKNAME parameter.
  • The APP business server must respond to this request within the timeout period.

Scenarios That May Trigger This Callback

  • When a user initiates a login request to go online through the client.
  • When the user's client successfully reconnects after a disconnection.
  • When setting a user's custom status.

Timing of Callback

  • When a user goes online.

Interface Description

Request URL Example

In the following example, the callback URL configured by the App is https://callbackurl.

https://callbackurl?command=$CallbackCommand&contenttype=json

Request Parameter Description

ParameterDescription
httpsThe request protocol is HTTPS, and the method is POST.
https://callbackurlCallback URL
CallbackCommandFixed value: callbackUserOnlineCommand
contenttypeFixed value: JSON
Header NameExample ValueOptionalTypeDescription
operationID1646445464564RequiredstringoperationID for global link tracing

Request Package Example

{
"userID": "user123",
"callbackCommand": "callbackUserOnlineCommand",
"seq": 123456,
"isAppBackground": false,
"connID": "conn123"
}

Request Package Field Description

FieldTypeDescription
userIDstringUnique identifier of the user.
callbackCommandstringCallback command, here for user online status callback.
seqint64Request sequence number.
isAppBackgroundboolIndicates if the user is in the app background.
connIDstringConnection identifier of the user.

Response Package Example

Processing Result

User is online.

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": ""
}

Response Package Field Description

FieldValueDescription
actionCode0Indicates whether the business system's callback was executed correctly. 0 means the operation was successful.
errCode0Custom error code, here 0 indicates the callback result is ignored.
errMsg"An error message"Simple error message corresponding to the custom error code.
errDlt"Detailed error information"Detailed error information corresponding to the custom error code.
nextCode1Next step command, 1 indicates refusal to continue execution, set when actionCode is 0.