UNPKG

radius-read

Version:

Realtime Dashboard

59 lines 3.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SocketIoClientRegisterService = void 0; /** * Service for managing Socket.IO client registrations. */ class SocketIoClientRegisterService { /** * Creates an instance of SocketIoClientRegisterService. */ constructor() { } /** * Registers a Socket.IO client by adding the provided client information to the list of registered clients. * @param clientInfo */ static register(clientInfo) { var _clientInfo = this._clientInfos.find(client => { var _a, _b; return (client === null || client === void 0 ? void 0 : client.callbackURL) === (clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.callbackURL) && ((_a = client === null || client === void 0 ? void 0 : client.userInfo) === null || _a === void 0 ? void 0 : _a.Token) === ((_b = clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.userInfo) === null || _b === void 0 ? void 0 : _b.Token); }); if (!_clientInfo) this._clientInfos.push(clientInfo); } /** * Unregisters a Socket.IO client by disconnecting the socket associated with the provided user information. * @param userInfo */ static unregister(userInfo) { var _a; var clientInfo = this._clientInfos.find(client => { var _a; return ((_a = client === null || client === void 0 ? void 0 : client.userInfo) === null || _a === void 0 ? void 0 : _a.Token) === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.Token); }); if (clientInfo) { (_a = clientInfo === null || clientInfo === void 0 ? void 0 : clientInfo.socket) === null || _a === void 0 ? void 0 : _a.disconnect(); } } /** * Clears the registered Socket.IO clients associated with the provided user information. * @param userInfo */ static clear(userInfo) { this._clientInfos = this._clientInfos.filter(client => { var _a; return ((_a = client === null || client === void 0 ? void 0 : client.userInfo) === null || _a === void 0 ? void 0 : _a.Token) !== (userInfo === null || userInfo === void 0 ? void 0 : userInfo.Token); }); } /** * Gets the registered Socket.IO client information for the provided user information. * @param userInfo * @returns */ static getSocket(userInfo) { var _a; return (_a = this._clientInfos.find(client => { var _a; return ((_a = client === null || client === void 0 ? void 0 : client.userInfo) === null || _a === void 0 ? void 0 : _a.Token) === (userInfo === null || userInfo === void 0 ? void 0 : userInfo.Token); })) === null || _a === void 0 ? void 0 : _a.socket; } } exports.SocketIoClientRegisterService = SocketIoClientRegisterService; /** * Client information for registered Socket.IO clients. * @date Jun 26, 2025 02:29:58 PM * @author Biswaranjan Nayak * * @private * @type {SocketIoClientInfo[]} */ SocketIoClientRegisterService._clientInfos = []; //# sourceMappingURL=socketio.client.register.service.js.map