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.
16 lines
522 B
16 lines
522 B
const express = require('express');
|
|
const app = express();
|
|
const http = require('http').Server(app);
|
|
const io = require('socket.io')(http);
|
|
const port = process.env.PORT || 3001;
|
|
|
|
app.use(express.static(__dirname + '/public'));
|
|
|
|
function onConnection(socket){
|
|
socket.on('message', (data) => socket.broadcast.emit('message', data));
|
|
socket.on('pushMessage', (data) => socket.broadcast.emit('pushMessage', data));
|
|
}
|
|
|
|
io.on('connection', onConnection);
|
|
|
|
http.listen(port, () => console.log('listening on port ' + port));
|