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.

19 lines
340 B

5 years ago
const socketio = require("socket.io");
5 years ago
let io: any
5 years ago
5 years ago
export function connect(server) {
io = socketio(server);
5 years ago
io.on('connection', client => {
console.log("=> [socket.io] connected!")
});
5 years ago
}
5 years ago
export const send = (body) => {
io.sockets.emit('message',body)
5 years ago
}
5 years ago
export const sendJson = (object) => {
5 years ago
send(JSON.stringify(object))
}