From 39a4514009194ba5045030c15932f2a0eac1c034 Mon Sep 17 00:00:00 2001 From: Gary Hunt Date: Mon, 21 Feb 2022 13:30:48 +0000 Subject: [PATCH] feat(ts) TypeScript enum for JitsiConnectionEvents --- JitsiConnectionEvents.js | 47 --------------- JitsiConnectionEvents.ts | 56 ++++++++++++++++++ types/auto/JitsiConnectionEvents.d.ts | 85 +++++++++++++++------------ 3 files changed, 102 insertions(+), 86 deletions(-) delete mode 100644 JitsiConnectionEvents.js create mode 100644 JitsiConnectionEvents.ts diff --git a/JitsiConnectionEvents.js b/JitsiConnectionEvents.js deleted file mode 100644 index 801099ae62..0000000000 --- a/JitsiConnectionEvents.js +++ /dev/null @@ -1,47 +0,0 @@ -/** - * The events for the connection. - */ - -/** - * Indicates that the connection has been disconnected. The event provides - * the following parameters to its listeners: - * - * @param msg {string} a message associated with the disconnect such as the - * last (known) error message - */ -export const CONNECTION_DISCONNECTED = 'connection.connectionDisconnected'; - -/** - * Indicates that the connection has been established. The event provides - * the following parameters to its listeners: - * - * @param id {string} the ID of the local endpoint/participant/peer (within - * the context of the established connection) - */ -export const CONNECTION_ESTABLISHED = 'connection.connectionEstablished'; - -/** - * Indicates that the connection has been failed for some reason. The event - * provides the following parameters to its listeners: - * - * @param errType {JitsiConnectionErrors} the type of error associated with - * the failure - * @param errReason {string} the error (message) associated with the failure - * @param credentials {object} the credentials used to connect (if any) - * @param errReasonDetails {object} an optional object with details about - * the error, like shard moving, suspending. Used for analytics purposes. - */ -export const CONNECTION_FAILED = 'connection.connectionFailed'; - -/** - * Indicates that the performed action cannot be executed because the - * connection is not in the correct state(connected, disconnected, etc.) - */ -export const WRONG_STATE = 'connection.wrongState'; - -/** - * Indicates that the display name is required over this connection and need to be supplied when - * joining the room. - * There are cases like lobby room where display name is required. - */ -export const DISPLAY_NAME_REQUIRED = 'connection.display_name_required'; diff --git a/JitsiConnectionEvents.ts b/JitsiConnectionEvents.ts new file mode 100644 index 0000000000..f242cb42e3 --- /dev/null +++ b/JitsiConnectionEvents.ts @@ -0,0 +1,56 @@ +/** + * The events for the connection. + */ + +export enum JitsiConnectionEvents { + /** + * Indicates that the connection has been disconnected. The event provides + * the following parameters to its listeners: + * + * @param msg {string} a message associated with the disconnect such as the + * last (known) error message + */ + CONNECTION_DISCONNECTED = 'connection.connectionDisconnected', + + /** + * Indicates that the connection has been established. The event provides + * the following parameters to its listeners: + * + * @param id {string} the ID of the local endpoint/participant/peer (within + * the context of the established connection) + */ + CONNECTION_ESTABLISHED = 'connection.connectionEstablished', + + /** + * Indicates that the connection has been failed for some reason. The event + * provides the following parameters to its listeners: + * + * @param errType {JitsiConnectionErrors} the type of error associated with + * the failure + * @param errReason {string} the error (message) associated with the failure + * @param credentials {object} the credentials used to connect (if any) + * @param errReasonDetails {object} an optional object with details about + * the error, like shard moving, suspending. Used for analytics purposes. + */ + CONNECTION_FAILED = 'connection.connectionFailed', + + /** + * Indicates that the performed action cannot be executed because the + * connection is not in the correct state(connected, disconnected, etc.) + */ + WRONG_STATE = 'connection.wrongState', + + /** + * Indicates that the display name is required over this connection and need to be supplied when + * joining the room. + * There are cases like lobby room where display name is required. + */ + DISPLAY_NAME_REQUIRED = 'connection.display_name_required' +}; + +// exported for backward compatibility +export const CONNECTION_DISCONNECTED = JitsiConnectionEvents.CONNECTION_DISCONNECTED; +export const CONNECTION_ESTABLISHED = JitsiConnectionEvents.CONNECTION_ESTABLISHED; +export const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED; +export const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE; +export const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED; diff --git a/types/auto/JitsiConnectionEvents.d.ts b/types/auto/JitsiConnectionEvents.d.ts index 3365e0b468..7cdf5fc5ac 100644 --- a/types/auto/JitsiConnectionEvents.d.ts +++ b/types/auto/JitsiConnectionEvents.d.ts @@ -1,42 +1,49 @@ /** * The events for the connection. */ -/** - * Indicates that the connection has been disconnected. The event provides - * the following parameters to its listeners: - * - * @param msg {string} a message associated with the disconnect such as the - * last (known) error message - */ -export const CONNECTION_DISCONNECTED: "connection.connectionDisconnected"; -/** - * Indicates that the connection has been established. The event provides - * the following parameters to its listeners: - * - * @param id {string} the ID of the local endpoint/participant/peer (within - * the context of the established connection) - */ -export const CONNECTION_ESTABLISHED: "connection.connectionEstablished"; -/** - * Indicates that the connection has been failed for some reason. The event - * provides the following parameters to its listeners: - * - * @param errType {JitsiConnectionErrors} the type of error associated with - * the failure - * @param errReason {string} the error (message) associated with the failure - * @param credentials {object} the credentials used to connect (if any) - * @param errReasonDetails {object} an optional object with details about - * the error, like shard moving, suspending. Used for analytics purposes. - */ -export const CONNECTION_FAILED: "connection.connectionFailed"; -/** - * Indicates that the performed action cannot be executed because the - * connection is not in the correct state(connected, disconnected, etc.) - */ -export const WRONG_STATE: "connection.wrongState"; -/** - * Indicates that the display name is required over this connection and need to be supplied when - * joining the room. - * There are cases like lobby room where display name is required. - */ -export const DISPLAY_NAME_REQUIRED: "connection.display_name_required"; +export declare enum JitsiConnectionEvents { + /** + * Indicates that the connection has been disconnected. The event provides + * the following parameters to its listeners: + * + * @param msg {string} a message associated with the disconnect such as the + * last (known) error message + */ + CONNECTION_DISCONNECTED = "connection.connectionDisconnected", + /** + * Indicates that the connection has been established. The event provides + * the following parameters to its listeners: + * + * @param id {string} the ID of the local endpoint/participant/peer (within + * the context of the established connection) + */ + CONNECTION_ESTABLISHED = "connection.connectionEstablished", + /** + * Indicates that the connection has been failed for some reason. The event + * provides the following parameters to its listeners: + * + * @param errType {JitsiConnectionErrors} the type of error associated with + * the failure + * @param errReason {string} the error (message) associated with the failure + * @param credentials {object} the credentials used to connect (if any) + * @param errReasonDetails {object} an optional object with details about + * the error, like shard moving, suspending. Used for analytics purposes. + */ + CONNECTION_FAILED = "connection.connectionFailed", + /** + * Indicates that the performed action cannot be executed because the + * connection is not in the correct state(connected, disconnected, etc.) + */ + WRONG_STATE = "connection.wrongState", + /** + * Indicates that the display name is required over this connection and need to be supplied when + * joining the room. + * There are cases like lobby room where display name is required. + */ + DISPLAY_NAME_REQUIRED = "connection.display_name_required" +} +export declare const CONNECTION_DISCONNECTED = JitsiConnectionEvents.CONNECTION_DISCONNECTED; +export declare const CONNECTION_ESTABLISHED = JitsiConnectionEvents.CONNECTION_ESTABLISHED; +export declare const CONNECTION_FAILED = JitsiConnectionEvents.CONNECTION_FAILED; +export declare const WRONG_STATE = JitsiConnectionEvents.WRONG_STATE; +export declare const DISPLAY_NAME_REQUIRED = JitsiConnectionEvents.DISPLAY_NAME_REQUIRED;