[]
        
(Showing Draft Content)

Connection

Class: Connection

Represents a client-side collaboration connection.

Table of contents

Constructors

Accessors

Methods

Constructors

constructor

new Connection()

Accessors

connected

get connected(): boolean

Indicates whether the connection is active and able to send messages.

Returns

boolean

True if the connection is active, false otherwise.


id

get id(): string

Retrieves the unique identifier of the connection.

Returns

string

The connection's ID.


roomId

get roomId(): string

Retrieves the room identifier of the connection.

Returns

string

The room ID associated with the connection.

Methods

close

close(): void

Closes the connection to the server.

Returns

void


destroy

destroy(): void

Destroys the observable and cleans up resources.

Returns

void


off

off<NAME>(name, f): void

Removes a listener for a specific event.

Type parameters

Name Type Description
NAME extends keyof IConnectionEvents The type of the event name, extending keyof IConnectionEvents.

Parameters

Name Type Description
name NAME The name of the event to remove the listener from.
f IConnectionEvents[NAME] The event handler function to remove.

Returns

void


on

on<NAME>(name, f): IConnectionEvents[NAME]

Register a listener for a specific event.

Type parameters

Name Type Description
NAME extends keyof IConnectionEvents The type of the event name, extending keyof IConnectionEvents.

Parameters

Name Type Description
name NAME The name of the event to listen for.
f IConnectionEvents[NAME] The event handler function.

Returns

IConnectionEvents[NAME]


once

once<NAME>(name, f): void

Registers a one-time listener for a specific event.

Type parameters

Name Type Description
NAME extends keyof IConnectionEvents The type of the event name, extending keyof IConnectionEvents.

Parameters

Name Type Description
name NAME The name of the event to listen for.
f IConnectionEvents[NAME] The event handler function to be called once.

Returns

void


send

send(data, type?): void

Sends a message to the server.

Parameters

Name Type Description
data unknown The data to send.
type? MessageType -

Returns

void