Through simple tracking of the mouse position, we can get the coordinates and broadcast the location over PubNub to any other viewers. We can also listen for keystrokes to broadcast the text changes along with the mouse position coordinates.
With PubNub, it's simple to send arbitrary data in realtime, including screen coordinates. In this example, we can send JSON objects containing the x- and y- coordinates of a mouse position within a publish()
call.
You can also display the number of users online with our Presence Detection API. presence()
receives user events including Join/Leave status changes. To use this optional API, you need to enable the feature on your Admin Dashboard and add the lines to your subscribe()
call.