mirror of
https://github.com/socketio/socket.io.git
synced 2026-01-09 23:18:02 -05:00
17 lines
441 B
JavaScript
17 lines
441 B
JavaScript
|
|
const express = require('express');
|
|
const app = express();
|
|
const http = require('http').Server(app);
|
|
const io = require('socket.io')(http);
|
|
const port = process.env.PORT || 3000;
|
|
|
|
app.use(express.static(__dirname + '/public'));
|
|
|
|
function onConnection(socket){
|
|
socket.on('drawing', (data) => socket.broadcast.emit('drawing', data));
|
|
}
|
|
|
|
io.on('connection', onConnection);
|
|
|
|
http.listen(port, () => console.log('listening on port ' + port));
|