ClientEvent
Defined in: src/client.ts:909
Enumeration Members
Section titled “Enumeration Members”AccountData
Section titled “AccountData”AccountData:
"accountData"
Defined in: src/client.ts:1072
Fires whenever new user-scoped account_data is added. The payload is a pair of event (DigitalWorldEvent) describing the account_data just added, and the previous event, if known:
- event: The event describing the account_data just added
- oldEvent: The previous account data, if known.
Example
Section titled “Example”digitalWorldClient.on("accountData", function(event, oldEvent){ myAccountData[event.type] = event.content;});ClientWellKnown
Section titled “ClientWellKnown”ClientWellKnown:
"WellKnown.client"
Defined in: src/client.ts:1104
Fires when the client .well-known info is fetched. The payload is the JSON object (see IClientWellKnown) returned by the server
DeleteRoom
Section titled “DeleteRoom”DeleteRoom:
"deleteRoom"
Defined in: src/client.ts:1098
Fires whenever a Room is removed. This will fire when you forget a room. This event is experimental and may change. The payload is the roomId of the deleted room.
Example
Section titled “Example”digitalWorldClient.on("deleteRoom", function(roomId){ // update UI from getRooms()});Event:
"event"
Defined in: src/client.ts:1035
Fires whenever the SDK receives a new event.
This is only fired for live events received via /sync - it is not fired for events received over context, search, or pagination APIs.
The payload is the event which caused this event to fire.
Example
Section titled “Example”digitalWorldClient.on("event", function(event){ var sender = event.getSender();});ReceivedToDeviceMessage
Section titled “ReceivedToDeviceMessage”ReceivedToDeviceMessage:
"receivedToDeviceMessage"
Defined in: src/client.ts:1059
Fires whenever the SDK receives a new (potentially decrypted) to-device message. The payload is the to-device message and the encryption info for that message (ReceivedToDeviceMessage).
Example
Section titled “Example”digitalWorldClient.on("receivedToDeviceMessage", function(payload){ const { message, encryptionInfo } = payload; var claimed_sender = encryptionInfo ? encryptionInfo.sender : message.sender; var isVerified = encryptionInfo ? encryptionInfo.verified : false; var type = message.type;});
***
### ReceivedVoipEvent
> **ReceivedVoipEvent**: `"received_voip_event"`
Defined in: [src/client.ts:1105](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1105)
***
### Room
> **Room**: `"Room"`
Defined in: [src/client.ts:1086](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1086)
Fires whenever a new Room is added. This will fire when you are invited to aroom, as well as when you join a room. <strong>This event is experimental andmay change.</strong>
The payload is the newly created room, fully populated.
#### ExampledigitalWorldClient.on(“Room”, function(room){ var roomId = room.roomId; });
***
### Sync
> **Sync**: `"sync"`
Defined in: [src/client.ts:1020](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1020)
Fires whenever the SDK's syncing state is updated. The state can be one of:<ul>
<li>PREPARED: The client has synced with the server at least once and isready for methods to be called on it. This will be immediately followed bya state of SYNCING. <i>This is the equivalent of "syncComplete" in theprevious API.</i></li>
<li>CATCHUP: The client has detected the connection to the server might beavailable again and will now try to do a sync again. As this sync might takea long time (depending how long ago was last synced, and general serverperformance) the client is put in this mode so the UI can reflect tryingto catch up with the server after losing connection.</li>
<li>SYNCING : The client is currently polling for new events from the server.This will be called <i>after</i> processing latest events from a sync.</li>
<li>ERROR : The client has had a problem syncing with the server. If this iscalled <i>before</i> PREPARED then there was a problem performing the initialsync. If this is called <i>after</i> PREPARED then there was a problem pollingthe server for updates. This may be called multiple times even if the state isalready ERROR. <i>This is the equivalent of "syncError" in the previousAPI.</i></li>
<li>RECONNECTING: The sync connection has dropped, but not (yet) in a way thatshould be considered erroneous.</li>
<li>STOPPED: The client has stopped syncing with server due to stopClientbeing called.</li></ul>State transition diagram: +---->STOPPED | +----->PREPARED -------> SYNCING <--+ | ^ | ^ | | CATCHUP ----------+ | | | | ^ V | |null ——+ | +—–– RECONNECTING | | V V | +—––>ERROR ———————+
NB: ‘null’ will never be emitted by this event.
Transitions:<ul>
<li>`null -> PREPARED` : Occurs when the initial sync is completedfirst time. This involves setting up filters and obtaining push rules.
<li>`null -> ERROR` : Occurs when the initial sync failed first time.
<li>`ERROR -> PREPARED` : Occurs when the initial sync succeedsafter previously failing.
<li>`PREPARED -> SYNCING` : Occurs immediately after transitioningto PREPARED. Starts listening for live updates rather than catching up.
<li>`SYNCING -> RECONNECTING` : Occurs when the live update fails.
<li>`RECONNECTING -> RECONNECTING` : Can occur if the update callscontinue to fail, but the keepalive calls (to /versions) succeed.
<li>`RECONNECTING -> ERROR` : Occurs when the keepalive call also fails
<li>`ERROR -> SYNCING` : Occurs when the client has performed alive update after having previously failed.
<li>`ERROR -> ERROR` : Occurs when the client has failed to keepalivefor a second time or more.</li>
<li>`SYNCING -> SYNCING` : Occurs when the client has performed a liveupdate. This is called <i>after</i> processing.</li>
<li>`* -> STOPPED` : Occurs once the client has stopped syncing ortrying to sync after stopClient has been called.</li></ul>
The payloads consits of the following 3 parameters:
- state - An enum representing the syncing state. One of "PREPARED","SYNCING", "ERROR", "STOPPED".
- prevState - An enum representing the previous syncing state.One of "PREPARED", "SYNCING", "ERROR", "STOPPED" <b>or null</b>.
- data - Data about this transition.
#### ExampledigitalWorldClient.on(“sync”, function(state, prevState, data) { switch (state) { case “ERROR”: // update UI to say “Connection Lost” break; case “SYNCING”: // update UI to remove any “Connection Lost” message break; case “PREPARED”: // the client instance is ready to be queried. var rooms = digitalWorldClient.getRooms(); break; } });
***
### SyncUnexpectedError
> **SyncUnexpectedError**: `"sync.unexpectedError"`
Defined in: [src/client.ts:1099](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1099)
***
### ~~ToDeviceEvent~~
> **ToDeviceEvent**: `"toDeviceEvent"`
Defined in: [src/client.ts:1046](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1046)
:::caution[Deprecated]Use [ReceivedToDeviceMessage](/messaging-js/reference/client/enumerations/clientevent/#receivedtodevicemessage).Fires whenever the SDK receives a new to-device event.The payload is the event ([DigitalWorldEvent](/messaging-js/reference/client/classes/digitalworldevent/)) which caused this event to fire.:::
#### ExampledigitalWorldClient.on(“toDeviceEvent”, function(event){ var sender = event.getSender(); });
***
### TurnServers
> **TurnServers**: `"turnServers"`
Defined in: [src/client.ts:1106](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1106)
***
### TurnServersError
> **TurnServersError**: `"turnServers.error"`
Defined in: [src/client.ts:1107](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1107)
***
### UserProfileUpdate
> **UserProfileUpdate**: `"userProfileUpdate"`
Defined in: [src/client.ts:1108](https://gitlab.com/digitalworld/digital-world-messaging-js-sdk/-/blob/5c2fde2b276006cdad2d3b07ec9b2417ec83d598/src/client.ts#L1108)