lef_Tso
4 years ago
2 changed files with 33 additions and 0 deletions
@ -0,0 +1,15 @@ |
|||
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
|
|||
}); |
@ -0,0 +1,18 @@ |
|||
{ |
|||
"name": "server", |
|||
"version": "1.0.0", |
|||
"description": "", |
|||
"main": "index.js", |
|||
"scripts": { |
|||
"run": "node index.js", |
|||
"dev": "nodemon index.js" |
|||
}, |
|||
"keywords": [], |
|||
"author": "", |
|||
"license": "ISC", |
|||
"dependencies": { |
|||
"express": "^4.17.1", |
|||
"nodemon": "^2.0.7", |
|||
"socket.io": "^3.1.0" |
|||
} |
|||
} |
Loading…
Reference in new issue