-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (29 loc) · 1.04 KB
/
index.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
33
34
35
36
37
38
39
const app = require("express")();
const server = require("http").Server(app);
const io = require("socket.io")(server);
const port = process.env.PORT || 3000;
server.listen(port, () => console.log(`Listening on ${port}`));
app.get("/", (req, res) => {
res.sendFile(__dirname + "/views/dashboard.html");
});
app.get("/sender", (req, res) => {
res.sendFile(__dirname + "/views/sender.html");
});
app.get("/css/style.css", (req, res) => {
res.sendFile(__dirname + "/public/css/style.css");
});
app.get("/audio/notification.mp3", (req, res) => {
res.sendFile(__dirname + "/public/audio/notification.mp3");
});
app.get("/audio/red-alert.mp3", (req, res) => {
res.sendFile(__dirname + "/public/audio/red-alert.mp3");
});
io.on("connection", (socket) => {
console.log("THERES A CONNECTION");
socket.on("join_room", (room) => socket.join(room));
socket.on("disconnect", () => console.log("THERE GOES A CONNECTION"));
socket.on("send_sender", (data) => {
console.log(data);
socket.to(data.room).emit("send_dashboard", data);
});
});