Ok, there are multiple ways in which the data flow can be mapped in terms of items.
In our simple chat implementation, we mapped items to chat rooms, so that different users could subscribe to different chat rooms and receive different data.
On the other hand, you can map a different item to each user, then feed each item with the data that pertains only to that user, depending on the chat rooms she is following.
For hints on the suggested way to work with user specific items, you may see the example in the
getItems javadoc.
There is no direct interface to receive a list of connected clients.
What you can do is to implement the notifyNewSession and notifySessionClose methods in your Metadata Adapter to keep track of all the client sessions.
When a client is connected, you should also assume that it will subscribe to the corresponding user-specific item;
if the user name is userA, we may call it "data_for_userA".
The client may send chat messages through the sendMessage method supplied by the client API and this will trigger the notifyUserMessage callback in the Metadata Adapter.
The client may also specify the requested chat rooms through the sendMessage method.
With these premises, the application can route each message to the pertaining clients by feeding the dedicated "data_for_*" items in the Data Adapter.
The above is needed regardless that there is one or multiple Server instances. In the latter case, however, the messages targeted to a user userB should be routed to the Server instance to which userB's client is connected (hence, whose Data Adapter has received the subscription request for the "data_for_userB" item). Unfortunately, this routing, as already pointed out by Gianluca, is not assisted by Lightstreamer.