-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
42 lines (37 loc) · 914 Bytes
/
server.js
File metadata and controls
42 lines (37 loc) · 914 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
33
34
35
36
37
38
39
40
41
42
var app = require("express")();
var http = require("http").Server(app);
var io = require("socket.io")(http);
app.get("*", function(req, res) {
if(req.url.indexOf("/.") >= 0) {
res.send("nope.");
} else {
res.sendFile(__dirname + req.url);
}
});
io.on("connection", function(socket) {
//console.log("someone's here");
socket.on("clear", function(data) {
socket.broadcast.emit("clear");
});
socket.on("start", function(data) {
socket.broadcast.emit("start");
});
socket.on("move", function(data) {
socket.broadcast.emit("move", data);
});
socket.on("stop", function(data) {
socket.broadcast.emit("stop");
});
socket.on("swap", function(data) {
io.emit("swap");
});
socket.on("swapnow", function(data) {
io.emit("swapnow");
});
socket.on("disconnect", function() {
//console.log("someone left");
});
});
http.listen(1138, function() {
console.log("listening on *:1138");
});