onUserStatusChanged
功能介绍
信息
已订阅用户的在线状态发生变化时,会触发此回调。
- iOS
- Android
- Flutter
- uni-app
- Browser/Electron/MiniProgram
- Unity
返回原型
enum OnlineState {
Online = 1,
Offline = 0,
}
type UserOnlineState = {
platformID: Platform;
status: OnlineState;
userID: string;
};
onUserStatusChanged(data: WSEvent<UserOnlineState>): void;
调用示例
import { getSDK, CbEvents } from '@openim/wasm-client-sdk';
// or
// import { OpenIMSDK, CbEvents } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
const IMSDK = getSDK();
IMSDK.on(
CbEvents.OnUserStatusChanged,
({ data }: WSEvent<UserOnlineState>) => {}
);
返回结果
名称 | 类型 | 描述 |
---|---|---|
data | WSEvent | - |
返回原型
enum OnlineState {
Online = 1,
Offline = 0,
}
type UserOnlineState = {
platformID: Platform;
status: OnlineState;
userID: string;
};
onUserStatusChanged(data: WSEvent<UserOnlineState>): void;
返回结果
名称 | 类型 | 描述 |
---|---|---|
data | WSEvent | - |
调用示例
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.subscribe(
IMSDK.IMEvents.OnUserStatusChanged,
({ data }: WSEvent<UserOnlineState>) => {}
);
返回原型
void OnUserStatusChanged(OnlineStatus userOnlineStatus);
返回结果
名称 | 类型 | 描述 |
---|---|---|
userOnlineStatus | OnlineStatus | 用户状态信息 |