Differences
This shows you the differences between two versions of the page.
| — |
en:comet:faq:realtime-users-list [2019/12/18 02:08] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ===== Subscription to update the list of users online ===== | ||
| + | <code JavaScript> | ||
| + | CometServer().subscription("track_online.subscription", function(msg) | ||
| + | { | ||
| + | // Processing of the event that someone went to the site and subscribed to the channel track_online | ||
| + | }); | ||
| + | CometServer().subscription("track_online.unsubscription", function(msg) | ||
| + | { | ||
| + | // Handling an event that someone left the site and / or unsubscribed from the track_online channel | ||
| + | }); | ||
| + | </code> | ||
| + | Open this page from different browsers and you will see incoming messages from CppComent about other users who opened or closed this page in other devices. | ||
| + | |||
| + | Example: | ||
| + | <html> | ||
| + | <iframe height='600' scrolling='no' title='CppComet auth chat example' src='//codepen.io/Levhav/embed/zLJarm/?height=265&theme-id=0&default-tab=js,result&embed-version=2' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/Levhav/pen/zLJarm/'>CppComet auth chat example</a> by Trapenok Victor (<a href='https://codepen.io/Levhav'>@Levhav</a>) on <a href='https://codepen.io'>CodePen</a>. | ||
| + | </iframe> | ||
| + | </html> | ||