Share User Data

This example uses Orbiter, JavaScript, and HTML to share user data among all occupants of a room. Each client that joins the application room shares data by setting shared attributes. The first shared attribute is "_PING", which can be automatically shared with other users by invoking ConnectionMonitor's sharePing() method. The second shared attribute is "occupation", which is set to one of three random values: "programmer", "designer", or "manager". Whenever a client sets an attribute, other occupants of the application room automatically notified via a RoomEvent.UPDATE_CLIENT_ATTRIBUTE event. Note that client attributes are temporary. When a client disconnects, its attributes are removed forever. To store and optionally share data permanently for reuse across multiple client sessions, use account attributes.

Here's the application:

[Edit Live on JSFiddle] [Download]

This application demonstrates the following Orbiter features:

  • Sharing ping times with connected users
  • Sharing a client attribute
  • Responding to client attribute updates
  • Joining an application room

The Code

Here is the code for the preceeding example. Click the "+" button to edit it live on JSFiddle.