You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
720 B

5 years ago
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
5 years ago
// import * as WebSocket from 'ws'
5 years ago
const socketio = require("socket.io");
5 years ago
let io;
5 years ago
// let srvr: any
5 years ago
function connect(server) {
5 years ago
// srvr = new WebSocket.Server({ server, clientTracking:true })
io = socketio(server);
5 years ago
io.on('connection', client => {
console.log("=> [socket.io] connected!");
5 years ago
});
5 years ago
}
5 years ago
exports.connect = connect;
5 years ago
exports.send = (body) => {
5 years ago
if (io)
io.sockets.emit('message', body);
5 years ago
// if(srvr){
// srvr.clients.forEach(c=>{
// if(c) c.send(body)
// })
// }
5 years ago
};
5 years ago
exports.sendJson = (object) => {
exports.send(JSON.stringify(object));
5 years ago
};
//# sourceMappingURL=socket.js.map