Type alias ClientEventHandlerMap

ClientEventHandlerMap: {
    Room: ((room) => void);
    WellKnown.client: ((data) => void);
    accountData: ((event, lastEvent?) => void);
    deleteRoom: ((roomId) => void);
    event: ((event) => void);
    received_voip_event: ((event) => void);
    sync: ((state, lastState, data?) => void);
    sync.unexpectedError: ((error) => void);
    toDeviceEvent: ((event) => void);
    toDeviceEvent.undecryptable: ((event) => void);
    turnServers: ((servers) => void);
    turnServers.error: ((error, fatal) => void);
} & RoomEventHandlerMap & RoomStateEventHandlerMap & CryptoEventHandlerMap & MatrixEventHandlerMap & RoomMemberEventHandlerMap & UserEventHandlerMap & CallEventHandlerEventHandlerMap & GroupCallEventHandlerEventHandlerMap & CallEventHandlerMap & HttpApiEventHandlerMap & BeaconEventHandlerMap

Type declaration

  • Room: ((room) => void)
      • (room): void
      • Fires whenever a new Room is added. This will fire when you are invited to a room, as well as when you join a room. This event is experimental and may change.

        Parameters

        • room: Room

          The newly created, fully populated room.

        Returns void

        Example

        matrixClient.on("Room", function(room){
        var roomId = room.roomId;
        });
  • WellKnown.client: ((data) => void)
      • (data): void
      • Fires when the client .well-known info is fetched.

        Parameters

        Returns void

  • accountData: ((event, lastEvent?) => void)
      • (event, lastEvent?): void
      • Fires whenever new user-scoped account_data is added.

        Parameters

        Returns void

        Example

        matrixClient.on("accountData", function(event, oldEvent){
        myAccountData[event.type] = event.content;
        });
  • deleteRoom: ((roomId) => void)
      • (roomId): void
      • Fires whenever a Room is removed. This will fire when you forget a room. This event is experimental and may change.

        Parameters

        • roomId: string

          The deleted room ID.

        Returns void

        Example

        matrixClient.on("deleteRoom", function(roomId){
        // update UI from getRooms()
        });
  • event: ((event) => void)
      • (event): void
      • 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.

        Parameters

        • event: MatrixEvent

          The matrix event which caused this event to fire.

        Returns void

        Example

        matrixClient.on("event", function(event){
        var sender = event.getSender();
        });
  • received_voip_event: ((event) => void)
      • (event): void
      • Parameters

        Returns void

  • sync: ((state, lastState, data?) => void)
      • (state, lastState, data?): void
      • Fires whenever the SDK's syncing state is updated. The state can be one of:

        • PREPARED: The client has synced with the server at least once and is ready for methods to be called on it. This will be immediately followed by a state of SYNCING. This is the equivalent of "syncComplete" in the previous API.
        • CATCHUP: The client has detected the connection to the server might be available again and will now try to do a sync again. As this sync might take a long time (depending how long ago was last synced, and general server performance) the client is put in this mode so the UI can reflect trying to catch up with the server after losing connection.
        • SYNCING : The client is currently polling for new events from the server. This will be called after processing latest events from a sync.
        • ERROR : The client has had a problem syncing with the server. If this is called before PREPARED then there was a problem performing the initial sync. If this is called after PREPARED then there was a problem polling the server for updates. This may be called multiple times even if the state is already ERROR. This is the equivalent of "syncError" in the previous API.
        • RECONNECTING: The sync connection has dropped, but not (yet) in a way that should be considered erroneous.
        • STOPPED: The client has stopped syncing with server due to stopClient being called.
        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 completed
        first 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 succeeds
        after previously failing.

        <li>`PREPARED -> SYNCING` : Occurs immediately after transitioning
        to 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 calls
        continue 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 a
        live update after having previously failed.

        <li>`ERROR -> ERROR` : Occurs when the client has failed to keepalive
        for a second time or more.</li>

        <li>`SYNCING -> SYNCING` : Occurs when the client has performed a live
        update. This is called <i>after</i> processing.</li>

        <li>`* -> STOPPED` : Occurs once the client has stopped syncing or
        trying to sync after stopClient has been called.</li>
        </ul>

        Parameters

        • state: SyncState

          An enum representing the syncing state. One of "PREPARED", "SYNCING", "ERROR", "STOPPED".

        • lastState: SyncState | null
        • Optional data: ISyncStateData

          Data about this transition.

        Returns void

        Example

        matrixClient.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 = matrixClient.getRooms();
        break;
        }
        });
  • sync.unexpectedError: ((error) => void)
      • (error): void
      • Parameters

        Returns void

  • toDeviceEvent: ((event) => void)
      • (event): void
      • Fires whenever the SDK receives a new to-device event.

        Parameters

        • event: MatrixEvent

          The matrix event which caused this event to fire.

        Returns void

        Example

        matrixClient.on("toDeviceEvent", function(event){
        var sender = event.getSender();
        });
  • toDeviceEvent.undecryptable: ((event) => void)
      • (event): void
      • Fires if a to-device event is received that cannot be decrypted. Encrypted to-device events will (generally) use plain Olm encryption, in which case decryption failures are fatal: the event will never be decryptable, unlike Megolm encrypted events where the key may simply arrive later.

        An undecryptable to-device event is therefore likley to indicate problems.

        Parameters

        Returns void

  • turnServers: ((servers) => void)
      • (servers): void
      • Parameters

        Returns void

  • turnServers.error: ((error, fatal) => void)
      • (error, fatal): void
      • Parameters

        • error: Error
        • fatal: boolean

        Returns void

Generated using TypeDoc