-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (35 loc) · 1.11 KB
/
index.js
File metadata and controls
44 lines (35 loc) · 1.11 KB
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
/*
---- HoloPaint ----
A holographic drawing app
Created by Nathan Piercy
Copyright (C) 2016
*/
var express = require("express");
var app = express();
var http = require("http").Server(app);
var io = require("socket.io")(http);
app.set("port", 1337);
app.use(express.static(__dirname + "/www"));
app.use("/jquery", express.static(__dirname + "/node_modules/jquery/dist")); // Ugh... jQuery
app.use("/spectrum-colorpicker", express.static(__dirname + "/node_modules/spectrum-colorpicker"));
http.listen(app.get("port"), function(){
console.log("listening on port " + app.get("port"));
});
var clientWidth = 0;
io.on("connection", function(socket){
console.log("connected: " + socket.handshake.address);
socket.on("disconnect", function(){
console.log("disconnected: " + socket.handshake.address);
});
socket.on("setWidth", function(width){
clientWidth = width;
socket.broadcast.emit("setWidth", clientWidth);
console.log("width set to " + width);
});
socket.on("getWidth", function(){
socket.emit("setWidth", clientWidth);
});
socket.on("draw", function(line){
socket.broadcast.emit("draw", line);
});
});