rtc basic chat application, with prototype of chat app

This commit is contained in:
2022-05-31 17:12:22 -05:00
commit 6cf11eb3ac
8 changed files with 1728 additions and 0 deletions

28
index.js Normal file
View File

@@ -0,0 +1,28 @@
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 + '/client/index.html');
});
io.on('connection', (socket) => {
socket.on('message', (msg) => {
io.emit('message', `${socket.id.substring(0,2)} says: ${msg}`);
});
socket.on('vote', (vote) => {
io.emit('vote', vote);
// io.emit('vote', voteData);
});
});
server.listen(8088, () => {
console.log('listening on port 8088');
});