This repository has been archived by the owner on May 29, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
69 lines (62 loc) · 1.6 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
password="defaultpassword";
if(process.argv[2]){
password=process.argv[2];
}
var http = require("http")
var express = require("express");
app = express();
server = http.createServer(app);
app.use(express.static(__dirname + '/presentation/'));
server.listen(3000);
app.get("/", function(req, res) {
res.sendfile('presentation/index.html');
});
app.get("/server", function(req, res) {
console.log("server connected!");
res.sendfile('presentation/index.html');
});
app.get("/client", function(req, res) {
console.log("client connected!");
res.end('support ended for the path client');
});
io = require('socket.io').listen(server);
io.sockets.on('connection', function(socket) {
process.soc=socket;
console.log("a user is connected!")
socket.on('chat', function(data) {
socket.broadcast.emit('chat', data);
console.log(data);
});
});
app.get("/next/:password", function(req, res) {
//console.log(req.params.password);
if(req.params.password==password){
console.log("Next Hit");
io.sockets.emit('chat','next');
res.end("next!");
}else{
res.end("inv");
console.log("Password Incorrect");
}
});
app.get("/prev/:password", function(req, res) {
//console.log(req.params.password);
if(req.params.password==password){
console.log("Next Hit");
io.sockets.emit('chat','prev');
res.end("prev!");
}else{
res.end("inv");
console.log("Password Incorrect");
}
});
app.get("/check/:password", function(req, res) {
console.log("check hit!");
//console.log(req.params.password);
if(req.params.password==password){
//io.sockets.emit('chat','check');
res.end("check");
}else{
res.end("inv");
}
});