Unity uClientCore > RemoteClientManager

RemoteClientManager Class




The UClient instance that created this RemoteClientManager.


getAttributeForClients(clientList, attributeScope, attributeName) Returns the value of the attribute specified by attributeScope and attributeName for all clients in clientList, which must be an array of client IDs.
getClient(clientID) Returns the specified RemoteClient instance, or null if the client specified isn't found.


The RemoteClientManager class provides access to RemoteClient instances, which store:

When the current client joins a room, the RemoteClientManager automatically adds a RemoteClient instance for each client in the room at the time of entry. All shared client attributes for each RemoteClient are populated at room-entry time. As clients enter and leave rooms, Unity automatically updates the RemoteClients stored by the RemoteClientManager. An object that implements URoomListener can access the RemoteClient objects in a room from URoomListener.onJoin() (the RemoteClient instances for the room are 100% initialized before onJoin() fires). This allows a room listener to display, say, a list of user names when the current client joins a room.

Clients can set shared attributes using UClient.setClientAttribute(). When a shared attribute is set, it is automatically propogated to all other clients, and can be accessed via RemoteClientManager.getClient().getAttribute().

For example, the following code retrieves the global shared attribute "playerName" for client ID 349:

var name = someUClient.getRemoteClientManager().getClient(349).getAttribute(null, "playerName");

RemoteClientManager.getAttributeForClients() Method


theRemoteClientManager.getAttributeForClients(clientList, attributeScope, attributeName)


An array of client IDs.
The fully qualified id of the room to which the attribute is scoped. Use null for global attributes.
The name of the attribute to retrieve.


Returns an array of objects containing value of the specified attribute for the clients in clientList. Each object in the array has a clientID property (giving the client id), and a value property (giving the attribute value). The value property will be undefined for clients in clientList that either do not exist or do not have a value set for the specified attribute.


The following code displays all value of the global username attribute for all clients in the room moock.chat:

var clientList = getRoomManager().getRoom("moock.chat").getClientIDs();
var attrList = getRemoteClientManager().getAttributeForClients(clientList, null, "username");
for(var i = 0; i < attrList.length; i++) {
  trace("The value of 'username' for client " + attrList[i].clientID + " is: " + attrList[i].value);

Documentation Version