官方包 · 实时功能组件

最多 100,000 人的 presence 频道

面向大型直播观众的在线人数和成员列表:客户端收到的是成员样本和批量的加入/离开人数,而不是每一位成员,需要时再分页加载其余成员。

  • presence-large-* 频道最多可容纳 100,000 名成员。
  • 成员人数和限制在您指定大小内的成员列表,每秒更新一次。
  • 可与 pusher-js 和 Laravel Echo 配合使用。

登录后,示例代码会自动填入您的集群主机。 登录

  1. 安装

    npm install @hibira-io/large-presence pusher-js
  2. 使用

    import { LargePresence } from '@hibira-io/large-presence';
    
    const pusher = new Pusher('YOUR_APP_KEY', {
      cluster: 'hkg',
      wsHost: 'ws.hibira.io',
      channelAuthorization: { endpoint: '/broadcasting/auth' },
    });
    const room = LargePresence.subscribe(pusher, 'presence-large-live.42', { maxMembers: 1000 });
    room.on('change', ({ count }) => showViewers(count));

开始之前

  • 私有频道和 presence 频道需要后端提供授权端点,用应用密钥签名订阅,做法与 pusher-js 相同。

请使用控制台中应用的 Key;Secret 只放在你的服务器上。频道、事件与授权端点的用法与 Pusher 完全相同。 免费创建账号 →