-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (26 loc) · 836 Bytes
/
index.js
File metadata and controls
34 lines (26 loc) · 836 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 express = require('express');
var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
app.use(express.static('public'));
app.get('/door-open', function(req, res){
io.sockets.emit('event',{type:'door-open'});
console.log('Door open event!')
res.json({"success": "true"});
});
app.get('/special-door-open', function(req, res){
io.sockets.emit('event',{type:'forceSpecialDoorOpen'});
console.log('Special door open event!')
res.json({"success": "true"});
});
app.get('/refresh', function(req, res){
io.sockets.emit('event',{type:'refresh'});
console.log('Refresh event!')
res.json({"success": "true"});
});
http.listen(3000, function(){
console.log('listening on *:3000');
});
io.on('connection', function(socket){
console.log('a user connected');
});