Skip to content

Commit

Permalink
Removed Socket.IO dendency.
Browse files Browse the repository at this point in the history
  • Loading branch information
dalewebster48 committed May 25, 2017
1 parent 9c90757 commit f9dbe74
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
3 changes: 0 additions & 3 deletions Layouts/Layout.json

This file was deleted.

16 changes: 8 additions & 8 deletions lib/ever-layout-bridge.js
Expand Up @@ -62,30 +62,30 @@ if (fs.existsSync(imageDirectory) == false) {
// })
// });

var network = require("../lib/network");
network = require("../lib/network");
network.createServer(port);

// Watch the layouts directory for changes
watch(layoutDirectory , {recursive:true} , function(event , filename){

// File name is likely a directory path, but we only
// want the filename
console.log(filename);
var realName = filename.split("/");
console.log(realName);
realName = realName[realName.length - 1];

fs.readFile(filename , function(err , data){
if (err) return console.log("There was an error");
console.log("Serving " + realName);
// Parse the JSON from the file
// socket.emit("layout-update" , {

console.log(data);

// network.sendData({
// "layoutName": realName,
// "layout": data
// });

network.sendData({
"layoutName": realName,
"layout": data
});
network.sendData(data);
});
});

Expand Down
13 changes: 8 additions & 5 deletions lib/network.js
Expand Up @@ -5,6 +5,8 @@ var network = {
clients : [],
createServer : function (port) {
net.createServer(function(socket){
console.log("Yo");

// Identify this client
socket.name = socket.remoteAddress + ":" + socket.remotePort

Expand All @@ -20,16 +22,17 @@ var network = {

// Remove the client from the list when it leaves
socket.on('end', function () {
clients.splice(clients.indexOf(socket), 1);
network.clients.splice(clients.indexOf(socket), 1);
console.log(socket.name + " disconnected");
});
} , port);
}).listen(port);
},
sendData : function (data) {
clients.forEach(function (client) {
network.clients.forEach(function (client) {
// Don't want to send it to sender
if (client === sender) return;
client.write(message);

// client.write(JSON.stringify(data));
client.write(data);
});
}
};
Expand Down
5 changes: 2 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "ever-layout-bridge",
"version": "1.1.1",
"version": "2.0",
"description": "A small server application to accompany the EverLayout library for iOS",
"main": "ever-layout-bridge.js",
"bin": {
Expand All @@ -11,7 +11,6 @@
"dependencies": {
"minimist": "^1.2.0",
"node-watch": "^0.5.1",
"rootpath": "^0.1.2",
"socket.io": "^1.7.2"
"rootpath": "^0.1.2"
}
}

0 comments on commit f9dbe74

Please sign in to comment.