added functionality to handle all server errors and added example in TCP basic world server. fixes #56

This commit is contained in:
Brandon Nozaki Miller 2016-01-04 01:00:08 -08:00
parent bbb9ed0369
commit e8bc96b6f4
2 changed files with 22 additions and 0 deletions

View file

@ -33,4 +33,11 @@ ipc.serveNet(
} }
); );
ipc.server.on(
'error',
function(err){
ipc.log('Got an ERROR!'.warn,err)
}
)
ipc.server.start(); ipc.server.start();

View file

@ -138,6 +138,7 @@ function init(path,config,log,port){
socket.address, socket.address,
function(err, bytes) { function(err, bytes) {
if(err){ if(err){
server.log('error writing data to socket'.warn,err);
server.trigger( server.trigger(
'error', 'error',
function(err){ function(err){
@ -161,6 +162,18 @@ function init(path,config,log,port){
); );
} }
server.server.on(
'error',
function(err){
server.log('server error'.warn,err);
server.trigger(
'error',
err
)
}
)
function serverCreated(socket) { function serverCreated(socket) {
server.sockets.push(socket); server.sockets.push(socket);
@ -181,6 +194,8 @@ function init(path,config,log,port){
socket.on( socket.on(
'error', 'error',
function(err){ function(err){
server.log('server socket error'.warn,err);
server.trigger('error',err); server.trigger('error',err);
} }
); );