[]
Represents a client-side collaboration connection.
• new Connection()
• get
connected(): boolean
Indicates whether the connection is active and able to send messages.
boolean
True if the connection is active, false otherwise.
• get
id(): string
Retrieves the unique identifier of the connection.
string
The connection's ID.
• get
roomId(): string
Retrieves the room identifier of the connection.
string
The room ID associated with the connection.
▸ close(): void
Closes the connection to the server.
void
▸ destroy(): void
Destroys the observable and cleans up resources.
void
▸ off<NAME
>(name
, f
): void
Removes a listener for a specific event.
Name | Type | Description |
---|---|---|
NAME |
extends keyof IConnectionEvents |
The type of the event name, extending keyof IConnectionEvents. |
Name | Type | Description |
---|---|---|
name |
NAME |
The name of the event to remove the listener from. |
f |
IConnectionEvents [NAME ] |
The event handler function to remove. |
void
▸ on<NAME
>(name
, f
): IConnectionEvents
[NAME
]
Register a listener for a specific event.
Name | Type | Description |
---|---|---|
NAME |
extends keyof IConnectionEvents |
The type of the event name, extending keyof IConnectionEvents. |
Name | Type | Description |
---|---|---|
name |
NAME |
The name of the event to listen for. |
f |
IConnectionEvents [NAME ] |
The event handler function. |
IConnectionEvents
[NAME
]
▸ once<NAME
>(name
, f
): void
Registers a one-time listener for a specific event.
Name | Type | Description |
---|---|---|
NAME |
extends keyof IConnectionEvents |
The type of the event name, extending keyof IConnectionEvents. |
Name | Type | Description |
---|---|---|
name |
NAME |
The name of the event to listen for. |
f |
IConnectionEvents [NAME ] |
The event handler function to be called once. |
void
▸ send(data
, type?
): void
Sends a message to the server.
Name | Type | Description |
---|---|---|
data |
unknown |
The data to send. |
type? |
MessageType |
- |
void