User Counter

The example below demonstrates how to display the number of users in a room. When embedded on a page, the code creates a room with the page's url as the room id, and then joins that room. The number of users in the room, hence, reflects the number of users viewing the page.

[View source]




The Code

Here's the code used to embed the user counter on a web page:

<span id="usercounter" style="background-color:#EEEEEE;margin-left:300px;padding:3px;border: 2px inset;border-color:#444444"></span>
<script type="text/javascript" src="http://unionplatform.com/cdn/OrbiterMicro_latest_min.js"></script>
<script type="text/javascript" src="http://www.unionplatform.com/samples/orbitermicro/UserCounter/OrbiterMicroUserCounter.js"></script>
<script type="text/javascript">
<!--
init();
//--></script>

Use View source, above, to view the code for the user counter.