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.
15 lines
473 B
15 lines
473 B
4 years ago
|
const app = require('express')();
|
||
|
const server = require('http').createServer(app);
|
||
|
const io = require('socket.io')(server);
|
||
|
|
||
|
io.on('connection', socket => {
|
||
|
console.log(`Client connected with id: ${socket.id}!`); // A client connects
|
||
|
|
||
|
socket.on('data', (data) => {
|
||
|
console.log('Received from client: ', data); // Received data from client
|
||
|
});
|
||
|
});
|
||
|
|
||
|
server.listen(3000, () => {
|
||
|
console.log('Server is listening on port 3000!'); // Started server
|
||
|
});
|