a2r
Version:
A2R Framework
21 lines (20 loc) • 754 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const socket_io_client_1 = require("socket.io-client");
const isClient_1 = __importDefault(require("../../tools/isClient"));
const devSettings_1 = require("../devSettings");
let socket = null;
const getSocket = async () => {
if (!socket) {
const settings = await (0, devSettings_1.getSettings)();
socket = (0, socket_io_client_1.io)(`localhost:${settings.server.port}`, {
autoConnect: (0, isClient_1.default)(),
path: '/ws',
});
}
return socket;
};
exports.default = getSocket;