-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
executable file
·76 lines (60 loc) · 1.77 KB
/
app.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
70
71
72
73
74
75
76
const express = require('express');
const app = express()();
var ejs = require('ejs');
const http = require('http').Server(app);
const io = require('socket.io')(http);
const port = process.env.PORT || 3000;
app.engine('ejs', require('ejs-locals'));
app.set('view engine', 'ejs');
var session = require('express-session')
app.use(session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: true
}))
app.use(express.static(__dirname + '/public'));
app.get("/", function(){
})
app.get("/login", function (req, res) {
console.log("here I am")
res.render(__dirname + '/views/index.ejs', {});
});
function onConnection(socket) {
socket.on('drawing', function (data) {
socket.broadcast.emit('drawing', data);
console.log(data);
});
socket.on('rectangle', function (data) {
socket.broadcast.emit('rectangle', data);
console.log(data);
});
socket.on('linedraw', function (data) {
socket.broadcast.emit('linedraw', data);
console.log(data);
});
socket.on('circledraw', function (data) {
socket.broadcast.emit('circledraw', data);
console.log(data);
});
socket.on('ellipsedraw', function (data) {
socket.broadcast.emit('ellipsedraw', data);
console.log(data);
});
socket.on('textdraw', function (data) {
socket.broadcast.emit('textdraw', data);
console.log(data);
});
socket.on('copyCanvas', function (data) {
socket.broadcast.emit('copyCanvas', data);
console.log(data);
});
socket.on('Clearboard', function (data) {
socket.broadcast.emit('Clearboard', data);
console.log(data);
});
}
io.on('connection', onConnection);
http.listen(port, () => {
// connect to DB
console.log('listening on port ' + port)
});