Browse Source

Add Server

master
lef_Tso 4 years ago
parent
commit
35998afbe7
  1. 15
      server/index.js
  2. 18
      server/package.json

15
server/index.js

@ -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
});

18
server/package.json

@ -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…
Cancel
Save