diff --git a/index.html b/index.html index ab33e5d..7653df3 100644 --- a/index.html +++ b/index.html @@ -19,5 +19,10 @@
-
+ + + + diff --git a/index.js b/index.js index 3ea66dd..b046c1e 100644 --- a/index.js +++ b/index.js @@ -2,11 +2,20 @@ const express = require('express'); const app = express(); const http = require("http"); const server = http.createServer(app); +const { Server } = require("socket.io"); +const io = new Server(server); app.get('/', (req, res) => { 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, () => { console.log('listening on beaglebone.local:3030'); }); diff --git a/package.json b/package.json index b5ea055..92810b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,8 @@ { - "name": "socket-chat-example", - "version": "0.0.1", - "description": "my first socket.io app", - "dependencies": {} + "name": "socket-chat-example", + "version": "0.0.1", + "description": "my first socket.io app", + "dependencies": { + "socket.io": "^4.4.1" + } }