-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
32 lines (31 loc) · 1.05 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const path = require('path')
app.use(bodyParser.json({ limit: '5000mb' }));
app.use(bodyParser.urlencoded({ limit: '5000mb', extended: true }));
const admin = require("firebase-admin");
const socketIO = require('socket.io');
const server = app.listen(3000, function(){
console.log("App started at 3000 (live video streaming)")
})
const io = socketIO(server);
app.use(express.static(path.join(__dirname, 'public')));
app.get("/", (req,res)=>{
res.sendFile(path.join(__dirname, 'public', 'live.html'));
})
const connectedClients = {};
io.on('connection' , socket => {
connectedClients[socket.id] = socket;
console.log("A user Connected " + " , " + socket.id);
socket.on("send", data=>{
io.emit("send0" , {
data2 : data.data1
})
})
socket.on('disconnect', () => {
delete connectedClients[socket.id];
socket.disconnect()
console.log('A user disconnected');
});
})