Skip to content

Commit

Permalink
aggiornamento cattura immagini da webcam
Browse files Browse the repository at this point in the history
  • Loading branch information
vrobbi committed Jul 12, 2013
1 parent dff6107 commit 37a40f2
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 52 deletions.
87 changes: 84 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,31 @@
//Restrictions on HEROKU:
// Doesn't support installing dependencies with npm with node 0.8
// Doesn't support websocekts.

// Including libraries
var knox = require('knox');

var client = knox.createClient({
key: 'AKIAIDZAMIX2REQZACVA',
secret: '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'
, bucket: 'bucket222'
});
var stringafile ='';
var stringaip ='';
/*
var object = { foo: "bar" };
var string = JSON.stringify(object);
var req = client.put('/test/obj.json', {
'Content-Length': string.length
, 'Content-Type': 'application/json'
});
req.on('response', function(res){
if (200 == res.statusCode) {
console.log('saved to %s', req.url);
}
});
req.end(string);
*/
var app = require('http').createServer(handler),
io = require('socket.io').listen(app),
nstatic = require('node-static'); // for serving files
Expand All @@ -28,7 +50,7 @@ function handler (request, response) {
}

// Delete this row if you want to see debug messages
io.set('log level', 1);
io.set('log level', 1);

// Heroku doesn't support websockets so...
// Detect if heroku via config vars
Expand All @@ -37,13 +59,36 @@ io.set('log level', 1);
if (process.env.HEROKU === 'true') {
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
io.set("polling duration", 20);
});
}

// Listen for incoming connections from clients
io.sockets.on('connection', function (socket) {
/*
client.get('filelog.txt').on('response', function(res){
var miadata = new Date();
stringaip = socket.handshake.address.address + ' ' + miadata.getDate() +'/' + miadata.getMonth() + '/' + miadata.getYear()
+ ' ' + miadata.getHours() +':' + miadata.getMinutes() +':' + miadata.getSeconds();
// console.log(stringaip);
// console.log(res.headers);
res.setEncoding('utf8');
res.on('data', function(chunk){
// console.log(chunk);
stringafile = stringafile + chunk;
// console.log(stringafile);
});
}).end();
var buffer = new Buffer(stringafile + stringaip + '\n');
var headers = {
'Content-Type': 'text/plain'
};
client.putBuffer(buffer, '/filelog.txt', headers, function(err, res){
// Logic
});
*/
// Start listening for mouse move events
socket.on('mousemove', function (data) {

Expand All @@ -52,18 +97,54 @@ io.sockets.on('connection', function (socket) {
socket.broadcast.emit('moving', data);
});

socket.on('salvasulserver', function (data) {

// var object = { foo: data.dataserver };
var datidalclient = data.dataserver.replace(/^data:image\/\w+;base64,/, "");
var buf = new Buffer(datidalclient, 'base64');
//var string = 'scrivo qualche cosa';
var req = client.put(data.orario + '.png', {
'Content-Length': buf.length,
'Content-Type': 'image/png'
});
req.on('response', function(res){
if (200 == res.statusCode) {
// console.log('saved to %s', req.url);
}
});
req.end(buf);

});

socket.on('doppioclick', function (data) {

// This line sends the event (broadcasts it)
// to everyone except the originating client.
socket.broadcast.emit('doppioclickser', data);

});

socket.on('chat', function (data) {

// This line sends the event (broadcasts it)
// to everyone except the originating client.
socket.broadcast.emit('chatser', data);

});
socket.on('fileperaltri', function (data) {

// This line sends the event (broadcasts it)
// to everyone except the originating client.
socket.broadcast.emit('fileperaltriser', data);

});

socket.on('camperaltri', function (data) {

// This line sends the event (broadcasts it)
// to everyone except the originating client.
socket.broadcast.emit('camperaltriser', data);
});


});
31 changes: 21 additions & 10 deletions assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ top:6px;
left:3px;
border:1px green solid;
width:250px;
height:200px;
height:180px;
font-size:11px;
overflow:auto;
}
Expand All @@ -114,13 +114,8 @@ height:auto;

#frecce {
float:right;
background-color:#FFFFFF;
height:400px;
}


#frecce:hover {
background-color:#FFFF00;
background-color:transparent;
height:445px;
}

#paper {
Expand All @@ -129,10 +124,10 @@ background-color:#FFFF00;

#controlli {
position:absolute;
top:3px;
top:6px;
left:-285px;
width:300px;
height:400px;
height:480px;
background-color:#ffffff;
border:1px red solid;
z-index:10;
Expand All @@ -141,6 +136,22 @@ z-index:10;
left:0px;
}

#frecce:hover {
background-color:transparent;
}
#frecce:out {
background-color:transparent;
}

#monitorcam {
position:absolute;
top:0px;
left:170px;
width:320px;
height:240px;
border:2px green solid;
z-index:120
}
/*----------------------------
The Footer
-----------------------------*/
Expand Down
Loading

0 comments on commit 37a40f2

Please sign in to comment.