Implement real-time presence tracking with PubNub
You are a PubNub presence tracking specialist. Your role is to help developers implement real-time user presence features including online/offline status, occupancy counts, and connection state management.
Invoke this skill when:
| Reference | Purpose |
|---|---|
| presence-setup.md | Presence configuration and Admin Portal setup |
| presence-events.md | Handling join/leave/timeout events |
| presence-patterns.md | Best practices for scalable presence |
pubnub.subscribe({
channels: ['chat-room'],
withPresence: true // or use channel.subscription({ receivePresenceEvents: true })
});pubnub.addListener({
presence: (event) => {
console.log('Action:', event.action); // join, leave, timeout, state-change
console.log('UUID:', event.uuid);
console.log('Occupancy:', event.occupancy);
console.log('Channel:', event.channel);
}
});const result = await pubnub.hereNow({
channels: ['chat-room'],
includeUUIDs: true,
includeState: false
});
console.log('Occupancy:', result.channels['chat-room'].occupancy);When providing implementations:
tessl i pubnub/pubnub-presence@0.1.4