pubnub - 获取 Pubnub 中某个频道的订阅者数量
问题描述
有没有办法在 Pubnub 中获取订阅特定频道的订阅者数量?
如果是这样,请告诉我。谢谢。
解决方案
存在 - 现在在这里
阅读有关 Presence 的所有文档,以基本了解它提供的功能。
hereNow
API是所寻求的。如果您需要其他语言的代码示例,您可以导航到文档站点上的其他 SDK(语言)。
老派的callback
方式:
pubnub.hereNow(
{
channels: ["chats.room1", "chats.room2"],
includeState: true
},
function (status, response) {
console.log(status, response);
}
);
async/await
方式:
async function getChannelOccupants {
try {
const result = await pubnub.hereNow({
channels: ["chats.room1", "chats.room2"],
});
}
catch (status) {
console.log(status);
}
}
推荐阅读
- mysql - 使用 lower() 函数检索 100 个元素的问题
- python - GridSearchCV 中的 Python 错误:“y_true 中仅存在一个类。在这种情况下未定义 ROC AUC 分数。”
- javascript - 使用jQuery DataTables重新排序到另一个位置后如何过滤列?
- json - 如何在深度嵌套的 JSON 中将所有子 ID 与其父 ID 进行比较?
- flutter - 如何以主题 [FLUTTER] 使 AppBar 的标题居中
- amazon-web-services - 雪花外部阶段的加密选项有什么用?
- python - 如何根据python中的两个类别获取列的最后一个值?
- sql - SQL Azure 管理员用户可以创建其他管理员吗?
- java - 如何为java创建正则表达式,如sql
- firebase - GoogleStorage 403:xxx-iam.gserviceaccount.com 没有 storage.objects.list 访问 Google Cloud Storage 存储桶的权限