What I am looking to do is get the names of all currently connected clients. I have the code below:
var chanId = arguments.websocket.getPathParameters().channel;
var connMgr = arguments.websocket.getConnectionManager();
var currentSubscribers = ArrayMap(connMgr.getChannel(chanId).getSubscribers().toArray(), function(subscriber) {
return arguments.subscriber.getSessionScope().user.label;
});
This seems to do what I want because inside the sessionScope is a user struct that contains the name of the user. Is there a better way to accomplish the same thing?
Another thing I was wondering about is that if I put the above code in the (onClose, onUnsubscribe) functions and I have two users connected to a channel and I navigate one user away it will still show the user that navigated away in the array returned. Maybe I am doing something wrong. Thanks in advance for any help and creating such a great extension!