Implement real-time presence tracking with PubNub
79
Quality
67%
Does it follow best practices?
Impact
98%
1.07xAverage score across 5 eval scenarios
You are building a team collaboration application using PubNub. Users frequently access the app from multiple devices at the same time -- for example, they may have the app open on both their laptop and phone. The "Who's Online" sidebar should show each team member at most once, even if they have multiple active sessions.
When a user closes one device but keeps the other open, they should remain in the online list. They should only disappear from the list when all their sessions are gone. The application should also be able to tell the difference between a user who intentionally signed off versus one whose connection was interrupted, so it can display different status indicators.
Implement a JavaScript presence event handler for PubNub that:
A single JavaScript file multi-device-presence.js containing the presence handler implementation.