الملفات
back_end_oudelaa/src/modules/chat/chat-realtime.service.ts
boutmoun123 ad6da6754d
بعض الفحوصات معلقة
Deploy To Ghaymah / deploy (push) Waiting to run
Emit realtime chat messages from REST sends
2026-05-28 01:15:31 +03:00

20 أسطر
500 B
TypeScript

import { Injectable } from '@nestjs/common';
import { Server } from 'socket.io';
@Injectable()
export class ChatRealtimeService {
private server?: Server;
bindServer(server: Server): void {
this.server = server;
}
emitNewMessage(conversationId: string, message: unknown): void {
this.server?.to(this.conversationRoom(conversationId)).emit('new_message', message);
}
private conversationRoom(conversationId: string): string {
return `conversation:${conversationId}`;
}
}