官方套件 · 即時功能元件
最多 100,000 人的 presence 頻道
給大型直播觀眾用的在線人數與成員清單:用戶端收到的是成員樣本與批次的加入/離開人數,而不是每一位成員,需要時再分頁載入其餘成員。
@hibira-io/large-presencenpm ↗GitHub ↗
- presence-large-* 頻道最多可容納 100,000 位成員。
- 成員人數與限制在您指定大小內的成員清單,每秒更新一次。
- 可搭配 pusher-js 與 Laravel Echo。
登入後,範例程式碼會自動帶入您的叢集主機。 登入
安裝
npm install @hibira-io/large-presence pusher-js使用
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 完全相同。 免費建立帳號 →