mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-24 02:32:28 +03:00
23 lines
538 B
JavaScript
23 lines
538 B
JavaScript
const WebSocket = require('ws');
|
|
const Logger = require('./utils/Logger');
|
|
const logger = new Logger();
|
|
|
|
class Socket {
|
|
constructor(server) {
|
|
this.webSocketServer = new WebSocket.Server({ server })
|
|
|
|
this.webSocketServer.on('listening', () => {
|
|
logger.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; |