diff --git a/Layouts/Layout.json b/Layouts/Layout.json deleted file mode 100644 index bf029e2..0000000 --- a/Layouts/Layout.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name":"Layout" -} \ No newline at end of file diff --git a/lib/ever-layout-bridge.js b/lib/ever-layout-bridge.js index c64115c..c63a1b2 100644 --- a/lib/ever-layout-bridge.js +++ b/lib/ever-layout-bridge.js @@ -62,7 +62,7 @@ if (fs.existsSync(imageDirectory) == false) { // }) // }); -var network = require("../lib/network"); +network = require("../lib/network"); network.createServer(port); // Watch the layouts directory for changes @@ -70,22 +70,22 @@ 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); }); }); diff --git a/lib/network.js b/lib/network.js index 17d9311..4b70696 100644 --- a/lib/network.js +++ b/lib/network.js @@ -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 @@ -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); }); } }; diff --git a/package.json b/package.json index 1bfde4d..cc62966 100644 --- a/package.json +++ b/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": { @@ -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" } }