|
@ -2,11 +2,20 @@ const express = require('express'); |
|
|
const app = express(); |
|
|
const app = express(); |
|
|
const http = require("http"); |
|
|
const http = require("http"); |
|
|
const server = http.createServer(app); |
|
|
const server = http.createServer(app); |
|
|
|
|
|
const { Server } = require("socket.io"); |
|
|
|
|
|
const io = new Server(server); |
|
|
|
|
|
|
|
|
app.get('/', (req, res) => { |
|
|
app.get('/', (req, res) => { |
|
|
res.sendFile(__dirname + '/index.html'); |
|
|
res.sendFile(__dirname + '/index.html'); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
io.on('connection', (socket) => { |
|
|
|
|
|
console.log('a new user connected'); |
|
|
|
|
|
socket.on('disconnect', () => { |
|
|
|
|
|
console.log('user disconnected'); |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
server.listen(3030, () => { |
|
|
server.listen(3030, () => { |
|
|
console.log('listening on beaglebone.local:3030'); |
|
|
console.log('listening on beaglebone.local:3030'); |
|
|
}); |
|
|
}); |
|
|