# CommentGateway

**Kind:** Class

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

WebSocket Gateway for real-time comment updates
Handles comment-specific WebSocket events and room management

**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` |
| `emitCommentAdded` | `emitCommentAdded(documentId: string, comment: CommentPayload)` | `void` |
| `emitCommentUpdated` | `emitCommentUpdated(documentId: string, comment: CommentPayload)` | `void` |
| `emitCommentDeleted` | `emitCommentDeleted(documentId: string, commentId: string)` | `void` |
| `emitCommentResolved` | `emitCommentResolved(documentId: string, data: {
      commentId: string;
      resolvedBy: { id: string; name: string; email: string };
      resolvedAt: Date;
    })` | `void` |
| `emitCommentUnresolved` | `emitCommentUnresolved(documentId: string, data: {
      commentId: string;
      unresolvedBy: { id: string; name: string; email: string };
    })` | `void` |
| `emitReplyAdded` | `emitReplyAdded(documentId: string, data: {
      parentCommentId: string;
      reply: CommentPayload;
    })` | `void` |
| `getDocumentCommentUsers` | `getDocumentCommentUsers(documentId: string)` | `CommentUserPresence[]` |
| `getDocumentCommentUserCount` | `getDocumentCommentUserCount(documentId: string)` | `number` |

## Properties

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

## Where it refuses work

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

## Referenced By

- `CommentModule` (MODULE_PROVIDES)
- `CommentModule` (MODULE_EXPORTS)
- `GatewayModule` (MODULE_PROVIDES)
- `GatewayModule` (MODULE_EXPORTS)
