Skip to content

Instantly share code, notes, and snippets.

@ragar90
Created February 22, 2015 23:07
Show Gist options
  • Save ragar90/641f00dd5193d1f9fa41 to your computer and use it in GitHub Desktop.
Save ragar90/641f00dd5193d1f9fa41 to your computer and use it in GitHub Desktop.
doorman_socket_edison
var socket = require('socket.io-client')('http://192.168.129.194:9000');
var fs = require("fs");
socket.on('connect', function(){
console.log('Connected!');
//*******
//TODO: User fedex guy picture
var image_origial = "back_to_the_future.jpg";
fs.readFile(image_origial, "base64", function(err,data){
if(err){
console.log(err);
console.log("Error");
}
else{
var socketData = {
image:{
base64String: data,
contentType: "image/jpg"
}
}
socket.emit('package_picture', socketData);
}
})
//******
});
socket.on('door_messages', function (socket_data) {
console.log('message from server: ' + msg);
if(socket_data.open){
//TODO: OPEN DOOR
}
else{
//TODO: CLOSE DOOR
}
});
socket.on('disconnect', function(){
console.log('Disconnected from server: ');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment