|
|
|
@ -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) |
|
|
|
|