mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-22 09:41:33 +03:00
21 lines
468 B
JavaScript
21 lines
468 B
JavaScript
const WebSocket = require('ws');
|
|
|
|
class Socket {
|
|
constructor(server) {
|
|
this.webSocketServer = new WebSocket.Server({ server })
|
|
|
|
this.webSocketServer.on('listening', () => {
|
|
console.log('Socket: listen');
|
|
})
|
|
|
|
this.webSocketServer.on('connection', (webSocketClient) => {
|
|
// console.log('Socket: new connection');
|
|
})
|
|
}
|
|
|
|
send(msg) {
|
|
this.webSocketServer.clients.forEach(client => client.send(msg));
|
|
}
|
|
}
|
|
|
|
module.exports = Socket; |