-
Notifications
You must be signed in to change notification settings - Fork 6
The current user's special object
The current user's object is an special hybrid object. As of v1.1 the current user's object has it own constructor and prototype, APS.cUser
. This object can directly receive events so it has a few methods that a channel would have like on()
, trigger()
, log()
. Therefore the channel's events message
and data
also apply to this object. Since the current user can not send events or publish to itself the methods pub()
and send()
are not present.
The update() method is unique to the current object user object. This method changes a public property of the user. For example assuming the the user has a property status
. If you change the the status like
client.user.status = "playing";
The change would only be visible in the current instance of the client, it wont propagate to other clients. In the other hand:
client.user.update("status", "playing");
Will change the status
property while it will also send the update to the server for propagation. The server will then send updates to all clients where a user reference exists.
Also if you want to listen or watch for property change such as status
you could add the following event handler:
client.user.on("userStatusUpdate", function(newValue, function( newValue ){
alert("Current User status changed to: " + newValue);
});
for more info in user properties event listeners check the Events list - userUpdate