# Connection

## Content

# Class: Connection

Represents a collaboration connection on the server.

## Table of contents

### Constructors

- [constructor](Connection#constructor)

### Accessors

- [auth](Connection#auth)
- [id](Connection#id)
- [query](Connection#query)
- [roomId](Connection#roomid)
- [tags](Connection#tags)

### Methods

- [broadcast](Connection#broadcast)
- [close](Connection#close)
- [send](Connection#send)

## Constructors

### <a id="constructor" name="constructor"></a> constructor

• **new Connection**()

## Accessors

### <a id="auth" name="auth"></a> auth

• `get` **auth**(): `Object`

Retrieves the authentication data of the connection.

#### Returns

`Object`

The authentication data associated with the connection.

___

### <a id="id" name="id"></a> id

• `get` **id**(): `string`

Retrieves the unique identifier of the connection.

#### Returns

`string`

The connection's ID.

___

### <a id="query" name="query"></a> query

• `get` **query**(): `Record`<`string`, `unknown`\>

Retrieves the query parameters of the connection.

#### Returns

`Record`<`string`, `unknown`\>

The query parameters of the connection.

___

### <a id="roomid" name="roomid"></a> roomId

• `get` **roomId**(): `string`

Retrieves the room identifier of the connection.

#### Returns

`string`

The room ID associated with the connection.

___

### <a id="tags" name="tags"></a> tags

• `get` **tags**(): `Map`<`string`, `unknown`\>

Retrieves the custom data saved for the connection.

#### Returns

`Map`<`string`, `unknown`\>

A map of custom tags for the connection.

## Methods

### <a id="broadcast" name="broadcast"></a> broadcast

▸ **broadcast**(`data`, `type?`, `includeSelf?`): `void`

Broadcasts a message to all connections in the room.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `unknown` | The message data to broadcast. |
| `type?` | [`MessageType`](../README#messagetype) | - |
| `includeSelf?` | `boolean` | - |

#### Returns

`void`

___

### <a id="close" name="close"></a> close

▸ **close**(): `void`

Closes the connection.

#### Returns

`void`

___

### <a id="send" name="send"></a> send

▸ **send**(`data`, `type?`): `void`

Sends a message to the client.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `data` | `unknown` | The message data to send. |
| `type?` | [`MessageType`](../README#messagetype) | - |

#### Returns

`void`
