forked from wesbos/HTML5-Security-Camera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
27 lines (18 loc) · 645 Bytes
/
server.js
File metadata and controls
27 lines (18 loc) · 645 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
// Including libraries
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
static = require('node-static'); // for serving files
var fileServer = new static.Server('./');
app.listen(8080);
// If the URL of the socket server is opened in a browser
function handler (request, response) {
request.addListener('end', function () {
fileServer.serve(request, response); // this will return the correct file
});
}
io.sockets.on('connection', function (socket) {
socket.on('sendImage', function (data) {
// console.log(data);
socket.broadcast.emit('getImage',data);
});
});