presence-room-42
실시간 채팅
presence 채널 위의 방, 멤버십, 입력 중 표시.
활용 사례
폴링하는 대시보드는 요청과 요청 사이 내내 틀려 있고, 얼마나 틀리게 두느냐에 비례해 비쌉니다. 바뀔 때 publish하면 그것이 뒤집힙니다.
초당 수백 번 움직이는 지표는 publish 전에 묶거나 표본을 뽑아야 합니다. 그 판단은 의미가 있는 곳, 즉 여러분 쪽에 속합니다.
// Start the aggregation when the first viewer arrives,// stop it when the last one leaves.for (const event of hook.getEvents()) { if (event.name === 'channel_occupied') startAggregation(event.channel) if (event.name === 'channel_vacated') stopAggregation(event.channel)}공식 Pusher 라이브러리를 손대지 않고 그대로 써서 작성했습니다. 설치할 PushCaster 패키지는 없습니다. 전체 문서