# RealtimeConnection

Class · extends `Events` · category: Internal

Source: https://github.com/playcanvas/editor-api/blob/4303c34bcee9a418297350899ad3a3f555526ec4/src/realtime/connection.ts#L24

Handles connecting and communicating with the Realtime server.

## Constructors

### constructor

```ts
new RealtimeConnection(realtime: Realtime)
```

Constructor

**Parameters**

- `realtime` ([`Realtime`](https://api.playcanvas.com/editor/classes/Realtime.md)): The realtime API

## Accessors

### authenticated

```ts
get authenticated(): boolean
```

Whether the server has authenticated the user

### connected

```ts
get connected(): boolean
```

Whether the user is connected to the server

### sharedb

```ts
get sharedb(): ShareDb
```

Gets the sharedb instance

## Methods

### connect

```ts
connect(url: string): void
```

Connect to the realtime server

**Parameters**

- `url` (`string`): The server URL

### disconnect

```ts
disconnect(): void
```

Disconnect from the server

### endBulkSubscribe

```ts
endBulkSubscribe(): void
```

Stop bulk subscribing to documents

### getDocument

```ts
getDocument(collection: string, id: number): Doc<any>
```

Gets a sharedb document

**Parameters**

- `collection` (`string`): The collection name
- `id` (`number`): The document id

**Returns** `Doc<any>`: The sharedb document

### send

```ts
send(data: string): Promise<void>
```

Sends a string to the server

**Parameters**

- `data` (`string`): The message data

**Returns** `Promise<void>`

### sendMessage

```ts
sendMessage(name: string, data: object): void
```

Send message to server

**Parameters**

- `name` (`string`): The message name
- `data` (`object`): The message data

### startBulkSubscribe

```ts
startBulkSubscribe(): void
```

Start bulk subscribing to documents
