Browse Source

FIX

pull/1/head
Vitalik 1 year ago
parent
commit
c383c3e991
  1. 2
      src/domain/real-time/real-time.module.ts
  2. 3
      src/domain/real-time/services/ws-server.service.ts

2
src/domain/real-time/real-time.module.ts

@ -11,7 +11,7 @@ export class RealTimeModule { @@ -11,7 +11,7 @@ export class RealTimeModule {
static getProviders() {
return [
provideClass(REAL_TIME_SERVICE, WsService),
MainGateway,
// MainGateway,
JwtWsGuard,
...REAL_TIME_SERVICES,
]

3
src/domain/real-time/services/ws-server.service.ts

@ -28,6 +28,7 @@ export class WsServerService { @@ -28,6 +28,7 @@ export class WsServerService {
* @param {string} key - ключ (назва) події
*/
public emit(key: string) {
if (!this.server) return
this.server.emit(key)
}
@ -47,6 +48,7 @@ export class WsServerService { @@ -47,6 +48,7 @@ export class WsServerService {
* @param {any} data - додаткові дані
*/
public emitToRoom(room: string, key: string, data?: any) {
if (!this.server) return
this.server.to(room).emit(key, data)
}
@ -66,6 +68,7 @@ export class WsServerService { @@ -66,6 +68,7 @@ export class WsServerService {
* @returns Повертає масив сокетів "кімнати"
*/
public getRoomSockets(room: string): string[] {
if (!this.server) return
try {
const roomsMap = this.server._nsps.get('/').adapter.rooms
const rooms = Object.fromEntries(roomsMap)

Loading…
Cancel
Save