Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
WuKongIM JavaScript SDK 频道管理功能,包括频道资料获取、订阅者管理和监听
class ChannelInfo { /* tslint:disable-line */ channel!: Channel; // 频道 title!: string; // 频道标题 logo!: string; // 频道logo mute!: boolean; // 是否免打扰 top!: boolean; // 是否置顶 orgData: any; // 第三方数据 online: boolean = false // 是否在线 lastOffline: number = 0 // 最后一次离线时间 }
class Subscriber { /* tslint:disable-line */ uid!: string; // 订阅者uid name!: string; // 订阅者名称 remark!: string; // 订阅者备注 avatar!: string; // 订阅者头像 role!: number; // 订阅者角色 channel!: Channel; // 频道 version!: number; // 数据版本 isDeleted!: boolean; // 是否已删除 status!: number; // 订阅者状态 orgData: any; // 第三方数据 }
需要实现获取频道资料的数据源
// 强制从服务器获取频道资料并放入缓存 WKSDK.shared().channelManager.fetchChannelInfo(channel)
// 从缓存获取频道资料 const channelInfo = WKSDK.shared().channelManager.getChannelInfo(channel)
WKSDK.shared().channelManager.fetchChannelInfo(channel)方法会触发此监听
const listen = (channelInfo: ChannelInfo) => { }
WKSDK.shared().channelManager.addListener(listen)
WKSDK.shared().channelManager.removeListener(listen)
需要实现同步频道订阅者数据源
WKSDK.shared().channelManager.syncSubscribes(channel)
const subscribers = WKSDK.shared().channelManager.getSubscribes(channel)
const subscriber = WKSDK.shared().channelManager.getSubscribeOfMe(channel)
const listen = (channel: Channel) => { const subscribers = WKSDK.shared().channelManager.getSubscribes(channel) }
WKSDK.shared().channelManager.addSubscriberChangeListener(listen)
WKSDK.shared().channelManager.removeSubscriberChangeListener(listen)