pythonasyncioeventletgeventlong-pollinglow-latencysocket-iosocketiosocketio-serverweb-serverwebsocket
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.
21 lines
540 B
21 lines
540 B
const express = require('express');
|
|
const app = express();
|
|
const server = require('http').createServer(app);
|
|
const io = require('socket.io')(server);
|
|
const port = process.env.PORT || 5000;
|
|
|
|
app.use(express.static(__dirname + '/fiddle_public'));
|
|
|
|
io.on('connection', socket => {
|
|
console.log(`connect ${socket.id}`);
|
|
|
|
socket.emit('hello', 1, '2', {
|
|
hello: 'you'
|
|
});
|
|
|
|
socket.on('disconnect', () => {
|
|
console.log(`disconnect ${socket.id}`);
|
|
});
|
|
});
|
|
|
|
server.listen(port, () => console.log(`server listening on port ${port}`));
|
|
|