space.members namespace in order to keep your avatar stack updated in realtime.
Event types
The following four event types are emitted by members:Subscribe to member events
Subscribe to members’ online status and profile updates by registering a listener. Member events are emitted whenever a member enters or leaves the space, or updates their profile data. Use thesubscribe() method on the members object of a space to receive updates.
It’s also possible to subscribe to multiple event types with the same listener by using an array:
Or subscribe to all event types:
The following is an example payload of a member event. The lastEvent.name describes which event type a payload relates to.
The following are the properties of a member event payload:
Unsubscribe from member events
Unsubscribe from member events to remove previously registered listeners. The following is an example of removing a listener for one member event type: It’s also possible to remove listeners for multiple member event types: Or remove all listeners:Retrieve members
Space membership can be retrieved in one-off calls. These are local calls and retrieve the membership retained in memory by the SDK. One-off calls to retrieve membership can be used for operations such as displaying a member’s own profile data to them, or retrieving a list of all other members to use to update their profile data. The following is an example of retrieving a member’s own member object: The following is an example payload returned byspace.members.getSelf():
The following is an example of retrieving an array of member objects for all members other than the member themselves. Ths includes members that have recently left the space, but have not yet been removed.
The following is an example payload returned by space.members.getOthers():
The following is an example of retrieving an array of all member objects, including the member themselves. Ths includes members that have recently left the space, but have not yet been removed.
The following is an example payload returned by space.members.getAll():
