Emit realtime chat messages from REST sends
بعض الفحوصات معلقة
Deploy To Ghaymah / deploy (push) Waiting to run
بعض الفحوصات معلقة
Deploy To Ghaymah / deploy (push) Waiting to run
هذا الالتزام موجود في:
19
src/modules/chat/chat-realtime.service.ts
Normal file
19
src/modules/chat/chat-realtime.service.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
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}`;
|
||||
}
|
||||
}
|
||||
المرجع في مشكلة جديدة
حظر مستخدم