# DocumentGateway

**Kind:** Class

**Source:** [`atloria-monorepo/apps/api/src/gateway/document.gateway.ts`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/api/src/gateway/document.gateway.ts#L23)

**Implements:** `OnGatewayConnection`, `OnGatewayDisconnect`

## Methods

| Method | Signature | Returns |
|---|---|---|
| `handleConnection` | `handleConnection(client: Socket)` | `void` |
| `handleDisconnect` | `handleDisconnect(client: Socket)` | `void` |
| `handleJoinDocument` | `handleJoinDocument(data: { documentId: string; userId: string; userName: string }, client: Socket)` | `void` |
| `handleLeaveDocument` | `handleLeaveDocument(data: { documentId: string }, client: Socket)` | `void` |
| `handleCursorUpdate` | `handleCursorUpdate(data: { documentId: string; position: any }, client: Socket)` | `void` |
| `handleSelectionUpdate` | `handleSelectionUpdate(data: { documentId: string; selection: any }, client: Socket)` | `void` |
| `emitToDocument` | `emitToDocument(documentId: string, event: string, data: any)` | `void` |
| `getDocumentUsers` | `getDocumentUsers(documentId: string)` | `UserPresence[]` |
| `getDocumentConnectionCount` | `getDocumentConnectionCount(documentId: string)` | `number` |

## Properties

| Property | Type |
|---|---|
| `server` | `Server` |

## Where it refuses work

- `DocumentGateway` stops the work with an early return when `!presenceMap`.

## Referenced By

- `CommentService` (DEPENDS_ON)
- `GatewayModule` (MODULE_PROVIDES)
- `GatewayModule` (MODULE_EXPORTS)
- `SuggestionService` (DEPENDS_ON)
