-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (29 loc) · 830 Bytes
/
server.js
File metadata and controls
32 lines (29 loc) · 830 Bytes
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
var app = require("express")();
var http = require("http").createServer(app);
var io = require("socket.io")(http);
io.on("connection", (socket) => {
// New Start
socket.on("new-start-request-status", (status) => {
emit("new-start-request-status", status);
});
// Send question
socket.on("new-question", (question) => {
emit("new-question", question);
});
// User answered question
socket.on("user-answered", (answer) => {
emit("user-answered", answer);
});
// Send info about question answer
socket.on("reply", (reply) => {
emit("reply", reply);
});
//Complete
socket.on("complete", (rightAnswers) => {
emit("complete", rightAnswers);
});
});
let emit = (event, parameters) => io.emit(event, parameters);
http.listen(5000, () => {
console.log("Socket running on :5000");
});