From: Carl Worth Date: Wed, 7 Dec 2022 04:11:15 +0000 (-0800) Subject: Make a socket connection from client to server X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=375b8a8984f8a9647e89974e786290d2ead855fa;hp=ae5194f5b4aedb94fb4f30d80043a74d1f5ada8b;p=zombocom-ai Make a socket connection from client to server Nothing useful yet, just a print on the server side to prove it's working. --- diff --git a/index.html b/index.html index 8eb3c6a..5a74b47 100644 --- a/index.html +++ b/index.html @@ -96,5 +96,10 @@ mute.addEventListener("click", () => { + + + diff --git a/index.js b/index.js index abacb59..336f36f 100644 --- a/index.js +++ b/index.js @@ -2,12 +2,18 @@ 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); const port = 2122; app.get('/index.html', (req, res) => { res.sendFile(__dirname + '/index.html'); }); +io.on('connection', (socket) => { + console.log('a user connected'); +}); + server.listen(port, () => { console.log(`listening on *:${port}`); });