@@ -888,78 +888,6 @@ interface IWhoamiResponse {
888
888
const EVENT_ID_PREFIX = "$" ;
889
889
890
890
export enum ClientEvent {
891
- Sync = "sync" ,
892
- Event = "event" ,
893
- /** @deprecated Use {@link ReceivedToDeviceMessage}. */
894
- ToDeviceEvent = "toDeviceEvent" ,
895
- ReceivedToDeviceMessage = "receivedToDeviceMessage" ,
896
- AccountData = "accountData" ,
897
- Room = "Room" ,
898
- DeleteRoom = "deleteRoom" ,
899
- SyncUnexpectedError = "sync.unexpectedError" ,
900
- ClientWellKnown = "WellKnown.client" ,
901
- ReceivedVoipEvent = "received_voip_event" ,
902
- UndecryptableToDeviceEvent = "toDeviceEvent.undecryptable" ,
903
- TurnServers = "turnServers" ,
904
- TurnServersError = "turnServers.error" ,
905
- }
906
-
907
- type RoomEvents =
908
- | RoomEvent . Name
909
- | RoomEvent . Redaction
910
- | RoomEvent . RedactionCancelled
911
- | RoomEvent . Receipt
912
- | RoomEvent . Tags
913
- | RoomEvent . LocalEchoUpdated
914
- | RoomEvent . HistoryImportedWithinTimeline
915
- | RoomEvent . AccountData
916
- | RoomEvent . MyMembership
917
- | RoomEvent . Timeline
918
- | RoomEvent . TimelineReset ;
919
-
920
- type RoomStateEvents =
921
- | RoomStateEvent . Events
922
- | RoomStateEvent . Members
923
- | RoomStateEvent . NewMember
924
- | RoomStateEvent . Update
925
- | RoomStateEvent . Marker ;
926
-
927
- type CryptoEvents = ( typeof CryptoEvent ) [ keyof typeof CryptoEvent ] ;
928
-
929
- type MatrixEventEvents = MatrixEventEvent . Decrypted | MatrixEventEvent . Replaced | MatrixEventEvent . VisibilityChange ;
930
-
931
- type RoomMemberEvents =
932
- | RoomMemberEvent . Name
933
- | RoomMemberEvent . Typing
934
- | RoomMemberEvent . PowerLevel
935
- | RoomMemberEvent . Membership ;
936
-
937
- type UserEvents =
938
- | UserEvent . AvatarUrl
939
- | UserEvent . DisplayName
940
- | UserEvent . Presence
941
- | UserEvent . CurrentlyActive
942
- | UserEvent . LastPresenceTs ;
943
-
944
- export type EmittedEvents =
945
- | ClientEvent
946
- | RoomEvents
947
- | RoomStateEvents
948
- | CryptoEvents
949
- | MatrixEventEvents
950
- | RoomMemberEvents
951
- | UserEvents
952
- | CallEvent // re-emitted by call.ts using Object.values
953
- | CallEventHandlerEvent . Incoming
954
- | GroupCallEventHandlerEvent . Incoming
955
- | GroupCallEventHandlerEvent . Outgoing
956
- | GroupCallEventHandlerEvent . Ended
957
- | GroupCallEventHandlerEvent . Participants
958
- | HttpApiEvent . SessionLoggedOut
959
- | HttpApiEvent . NoConsent
960
- | BeaconEvent ;
961
-
962
- export type ClientEventHandlerMap = {
963
891
/**
964
892
* Fires whenever the SDK's syncing state is updated. The state can be one of:
965
893
* <ul>
@@ -1042,13 +970,15 @@ export type ClientEventHandlerMap = {
1042
970
* trying to sync after stopClient has been called.</li>
1043
971
* </ul>
1044
972
*
1045
- * @param state - An enum representing the syncing state. One of "PREPARED",
973
+ * The payloads consits of the following 3 parameters:
974
+ *
975
+ * - state - An enum representing the syncing state. One of "PREPARED",
1046
976
* "SYNCING", "ERROR", "STOPPED".
1047
977
*
1048
- * @param prevState - An enum representing the previous syncing state.
978
+ * - prevState - An enum representing the previous syncing state.
1049
979
* One of "PREPARED", "SYNCING", "ERROR", "STOPPED" <b>or null</b>.
1050
980
*
1051
- * @param data - Data about this transition.
981
+ * - data - Data about this transition.
1052
982
*
1053
983
* @example
1054
984
* ```
@@ -1068,36 +998,36 @@ export type ClientEventHandlerMap = {
1068
998
* });
1069
999
* ```
1070
1000
*/
1071
- [ ClientEvent . Sync ] : ( state : SyncState , prevState : SyncState | null , data ?: ISyncStateData ) => void ;
1001
+ Sync = "sync" ,
1072
1002
/**
1073
1003
* Fires whenever the SDK receives a new event.
1074
1004
* <p>
1075
1005
* This is only fired for live events received via /sync - it is not fired for
1076
1006
* events received over context, search, or pagination APIs.
1077
1007
*
1078
- * @param event - The matrix event which caused this event to fire.
1008
+ * The payload is the matrix event which caused this event to fire.
1079
1009
* @example
1080
1010
* ```
1081
1011
* matrixClient.on("event", function(event){
1082
1012
* var sender = event.getSender();
1083
1013
* });
1084
1014
* ```
1085
1015
*/
1086
- [ ClientEvent . Event ] : ( event : MatrixEvent ) => void ;
1087
- /**
1016
+ Event = "event" ,
1017
+ /** @deprecated Use { @link ReceivedToDeviceMessage}.
1088
1018
* Fires whenever the SDK receives a new to-device event.
1089
- * @param event - The matrix event which caused this event to fire.
1019
+ * The payload is the matrix event ({ @link MatrixEvent}) which caused this event to fire.
1090
1020
* @example
1091
1021
* ```
1092
1022
* matrixClient.on("toDeviceEvent", function(event){
1093
1023
* var sender = event.getSender();
1094
1024
* });
1095
1025
* ```
1096
1026
*/
1097
- [ ClientEvent . ToDeviceEvent ] : ( event : MatrixEvent ) => void ;
1027
+ ToDeviceEvent = "toDeviceEvent" ,
1098
1028
/**
1099
- * Fires whenever the SDK receives a new to-device message.
1100
- * @param payload - The message and encryptionInfo for this message (See {@link ReceivedToDeviceMessage}) which caused this event to fire .
1029
+ * Fires whenever the SDK receives a new (potentially decrypted) to-device message.
1030
+ * The payload is the to-device message and the encryption info for that message ({@link ReceivedToDeviceMessage}).
1101
1031
* @example
1102
1032
* ```
1103
1033
* matrixClient.on("receivedToDeviceMessage", function(payload){
@@ -1106,64 +1036,137 @@ export type ClientEventHandlerMap = {
1106
1036
* var isVerified = encryptionInfo ? encryptionInfo.verified : false;
1107
1037
* var type = message.type;
1108
1038
* });
1109
- * ```
1110
1039
*/
1111
- [ ClientEvent . ReceivedToDeviceMessage ] : ( payload : ReceivedToDeviceMessage ) => void ;
1112
- /**
1113
- * Fires if a to-device event is received that cannot be decrypted.
1114
- * Encrypted to-device events will (generally) use plain Olm encryption,
1115
- * in which case decryption failures are fatal: the event will never be
1116
- * decryptable, unlike Megolm encrypted events where the key may simply
1117
- * arrive later.
1118
- *
1119
- * An undecryptable to-device event is therefore likely to indicate problems.
1120
- *
1121
- * @param event - The undecyptable to-device event
1122
- */
1123
- [ ClientEvent . UndecryptableToDeviceEvent ] : ( event : MatrixEvent ) => void ;
1040
+ ReceivedToDeviceMessage = "receivedToDeviceMessage" ,
1124
1041
/**
1125
1042
* Fires whenever new user-scoped account_data is added.
1126
- * @param event - The event describing the account_data just added
1127
- * @param event - The previous account data, if known.
1043
+ * The payload is a pair of event ({@link MatrixEvent}) describing the account_data just added, and the previous event, if known:
1044
+ * - event: The event describing the account_data just added
1045
+ * - oldEvent: The previous account data, if known.
1128
1046
* @example
1129
1047
* ```
1130
1048
* matrixClient.on("accountData", function(event, oldEvent){
1131
1049
* myAccountData[event.type] = event.content;
1132
1050
* });
1133
1051
* ```
1134
1052
*/
1135
- [ ClientEvent . AccountData ] : ( event : MatrixEvent , lastEvent ?: MatrixEvent ) => void ;
1053
+ AccountData = "accountData" ,
1136
1054
/**
1137
1055
* Fires whenever a new Room is added. This will fire when you are invited to a
1138
1056
* room, as well as when you join a room. <strong>This event is experimental and
1139
1057
* may change.</strong>
1140
- * @param room - The newly created, fully populated room.
1058
+ *
1059
+ * The payload is the newly created room, fully populated.
1141
1060
* @example
1142
1061
* ```
1143
1062
* matrixClient.on("Room", function(room){
1144
1063
* var roomId = room.roomId;
1145
1064
* });
1146
1065
* ```
1147
1066
*/
1148
- [ ClientEvent . Room ] : ( room : Room ) => void ;
1067
+ Room = "Room" ,
1149
1068
/**
1150
1069
* Fires whenever a Room is removed. This will fire when you forget a room.
1151
1070
* <strong>This event is experimental and may change.</strong>
1152
- * @param roomId - The deleted room ID .
1071
+ * The payload is the roomId of the deleted room.
1153
1072
* @example
1154
1073
* ```
1155
1074
* matrixClient.on("deleteRoom", function(roomId){
1156
1075
* // update UI from getRooms()
1157
1076
* });
1158
1077
* ```
1159
1078
*/
1160
- [ ClientEvent . DeleteRoom ] : ( roomId : string ) => void ;
1161
- [ ClientEvent . SyncUnexpectedError ] : ( error : Error ) => void ;
1079
+ DeleteRoom = "deleteRoom" ,
1080
+ SyncUnexpectedError = "sync.unexpectedError" ,
1162
1081
/**
1163
1082
* Fires when the client .well-known info is fetched.
1083
+ * The payload is the JSON object (see {@link IClientWellKnown}) returned by the server
1084
+ */
1085
+ ClientWellKnown = "WellKnown.client" ,
1086
+ ReceivedVoipEvent = "received_voip_event" ,
1087
+ /**
1088
+ * @deprecated This event is not supported anymore.
1164
1089
*
1165
- * @param data - The JSON object returned by the server
1090
+ * Fires if a to-device event is received that cannot be decrypted.
1091
+ * Encrypted to-device events will (generally) use plain Olm encryption,
1092
+ * in which case decryption failures are fatal: the event will never be
1093
+ * decryptable, unlike Megolm encrypted events where the key may simply
1094
+ * arrive later.
1095
+ *
1096
+ * An undecryptable to-device event is therefore likely to indicate problems.
1097
+ *
1098
+ * The payload is the undecyptable to-device event
1166
1099
*/
1100
+ UndecryptableToDeviceEvent = "toDeviceEvent.undecryptable" ,
1101
+ TurnServers = "turnServers" ,
1102
+ TurnServersError = "turnServers.error" ,
1103
+ }
1104
+
1105
+ type RoomEvents =
1106
+ | RoomEvent . Name
1107
+ | RoomEvent . Redaction
1108
+ | RoomEvent . RedactionCancelled
1109
+ | RoomEvent . Receipt
1110
+ | RoomEvent . Tags
1111
+ | RoomEvent . LocalEchoUpdated
1112
+ | RoomEvent . HistoryImportedWithinTimeline
1113
+ | RoomEvent . AccountData
1114
+ | RoomEvent . MyMembership
1115
+ | RoomEvent . Timeline
1116
+ | RoomEvent . TimelineReset ;
1117
+
1118
+ type RoomStateEvents =
1119
+ | RoomStateEvent . Events
1120
+ | RoomStateEvent . Members
1121
+ | RoomStateEvent . NewMember
1122
+ | RoomStateEvent . Update
1123
+ | RoomStateEvent . Marker ;
1124
+
1125
+ type CryptoEvents = ( typeof CryptoEvent ) [ keyof typeof CryptoEvent ] ;
1126
+
1127
+ type MatrixEventEvents = MatrixEventEvent . Decrypted | MatrixEventEvent . Replaced | MatrixEventEvent . VisibilityChange ;
1128
+
1129
+ type RoomMemberEvents =
1130
+ | RoomMemberEvent . Name
1131
+ | RoomMemberEvent . Typing
1132
+ | RoomMemberEvent . PowerLevel
1133
+ | RoomMemberEvent . Membership ;
1134
+
1135
+ type UserEvents =
1136
+ | UserEvent . AvatarUrl
1137
+ | UserEvent . DisplayName
1138
+ | UserEvent . Presence
1139
+ | UserEvent . CurrentlyActive
1140
+ | UserEvent . LastPresenceTs ;
1141
+
1142
+ export type EmittedEvents =
1143
+ | ClientEvent
1144
+ | RoomEvents
1145
+ | RoomStateEvents
1146
+ | CryptoEvents
1147
+ | MatrixEventEvents
1148
+ | RoomMemberEvents
1149
+ | UserEvents
1150
+ | CallEvent // re-emitted by call.ts using Object.values
1151
+ | CallEventHandlerEvent . Incoming
1152
+ | GroupCallEventHandlerEvent . Incoming
1153
+ | GroupCallEventHandlerEvent . Outgoing
1154
+ | GroupCallEventHandlerEvent . Ended
1155
+ | GroupCallEventHandlerEvent . Participants
1156
+ | HttpApiEvent . SessionLoggedOut
1157
+ | HttpApiEvent . NoConsent
1158
+ | BeaconEvent ;
1159
+
1160
+ export type ClientEventHandlerMap = {
1161
+ [ ClientEvent . Sync ] : ( state : SyncState , prevState : SyncState | null , data ?: ISyncStateData ) => void ;
1162
+ [ ClientEvent . Event ] : ( event : MatrixEvent ) => void ;
1163
+ [ ClientEvent . ToDeviceEvent ] : ( event : MatrixEvent ) => void ;
1164
+ [ ClientEvent . ReceivedToDeviceMessage ] : ( payload : ReceivedToDeviceMessage ) => void ;
1165
+ [ ClientEvent . UndecryptableToDeviceEvent ] : ( event : MatrixEvent ) => void ;
1166
+ [ ClientEvent . AccountData ] : ( event : MatrixEvent , lastEvent ?: MatrixEvent ) => void ;
1167
+ [ ClientEvent . Room ] : ( room : Room ) => void ;
1168
+ [ ClientEvent . DeleteRoom ] : ( roomId : string ) => void ;
1169
+ [ ClientEvent . SyncUnexpectedError ] : ( error : Error ) => void ;
1167
1170
[ ClientEvent . ClientWellKnown ] : ( data : IClientWellKnown ) => void ;
1168
1171
[ ClientEvent . ReceivedVoipEvent ] : ( event : MatrixEvent ) => void ;
1169
1172
[ ClientEvent . TurnServers ] : ( servers : ITurnServer [ ] ) => void ;
0 commit comments