fixed buffer error from issue #11

This commit is contained in:
Brandon Miller 2014-03-03 12:02:56 -08:00
parent 9df9066423
commit 7d8ecd1f7e
4 changed files with 26 additions and 2 deletions

View file

@ -15,7 +15,7 @@ ipc.serve(
ipc.server.on( ipc.server.on(
'app.message', 'app.message',
function(data,socket){ 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( ipc.server.emit(
socket, socket,
'app.message', 'app.message',

View file

@ -115,6 +115,18 @@ function connect(){
'data', 'data',
function(data) { function(data) {
client.log('## recieved events ##'.rainbow); 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 events = eventParser.parse(data);
var eCount = events.length; var eCount = events.length;
for(var i=0; i<eCount; i++){ for(var i=0; i<eCount; i++){

View file

@ -166,6 +166,18 @@ function init(path,config,log,port){
socket.on( socket.on(
'data', 'data',
function(data,UDPSocket){ function(data,UDPSocket){
if(!this.ipcBuffer)
this.ipcBuffer='';
data=(this.ipcBuffer+=data);
if(data.slice(-1)!=eventParser.delimiter){
server.log('Socket buffer size exceeded, consider smaller messages or a larger buffer.'.warn, 'Implementing software buffer expansion for this message.'.notice);
return;
}
this.ipcBuffer='';
data=eventParser.parse(data); data=eventParser.parse(data);
var sock=((server.udp4 || server.udp6)? UDPSocket : socket); var sock=((server.udp4 || server.udp6)? UDPSocket : socket);

View file

@ -1,6 +1,6 @@
{ {
"name": "node-ipc", "name": "node-ipc",
"version": "0.9.13", "version": "0.9.15",
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.", "description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
"main": "node-ipc.js", "main": "node-ipc.js",
"directories": { "directories": {