tvhnet2013
Hi,
In my chat app, I need to show connection status of chat room members. What is best practice?
Thanks in advance.
Dario Crivelli
In Lightstreamer terms, the connection status of a user consists in whether or not there is an open session for that user.
On the Server side, the Metadata Adapter can keep track of all the current sessions and their associated users by implementing notifyNewSessionand notifySessionClose . In this way, the list of currently connected users can be updated in real time and it can be made available to the clients as an item in COMMAND mode.
If you are interested in the presence of a user in a specific chat room, then the entrance and exit events are defined only by your application.
We suggest leaning on the user entering and exiting the room by subscribing to and unsubscribing from a specific item (note that the subscription expires automatically when the session is closed). In this way, the Metadata Adapter is notified through notifyNewTablesand notifyTablesClose .
If your getItemsimplementation "decorates" the item to make it user-specific (a topic shown in other posts), you can also check when you receive the subscribe and unsubscribe calls in the Data Adapter. This takes advantage of subscription management and it is simpler to use, because, upon a sudden disconnection and reconnection (possibly due to a network problem), the subscription may remain active, with no interruption, because of the configured <subscription_timeout_millis>.