From 7d8ecd1f7e47c7436cf0df9ba16c9721badbae2c Mon Sep 17 00:00:00 2001 From: Brandon Miller Date: Mon, 3 Mar 2014 12:02:56 -0800 Subject: [PATCH] fixed buffer error from issue #11 --- example/unixSocket/basic/world-server.js | 2 +- lib/client.js | 12 ++++++++++++ lib/socketServer.js | 12 ++++++++++++ package.json | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/example/unixSocket/basic/world-server.js b/example/unixSocket/basic/world-server.js index cd57127..7ad96e9 100644 --- a/example/unixSocket/basic/world-server.js +++ b/example/unixSocket/basic/world-server.js @@ -15,7 +15,7 @@ ipc.serve( ipc.server.on( 'app.message', function(data,socket){ - ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); + //ipc.log('got a message from'.debug, (data.id).variable, (data.message).data); ipc.server.emit( socket, 'app.message', diff --git a/lib/client.js b/lib/client.js index eb639a2..3cef496 100644 --- a/lib/client.js +++ b/lib/client.js @@ -115,6 +115,18 @@ function connect(){ 'data', function(data) { client.log('## recieved events ##'.rainbow); + if(!this.ipcBuffer) + this.ipcBuffer=''; + + data=(this.ipcBuffer+=data); + + if(data.slice(-1)!=eventParser.delimiter){ + client.log('Socket buffer size exceeded consider smaller messages or a larger buffer.'.warn, 'Implementing software buffer expansion for this message.'.notice); + return; + } + + this.ipcBuffer=''; + var events = eventParser.parse(data); var eCount = events.length; for(var i=0; i