collective-soundworks / soundworks

Creative coding framework for distributed applications based on Web technologies.
http://soundworks.dev
BSD 3-Clause "New" or "Revised" License
114 stars 7 forks source link

[template-helpers] propose default QoS for node clients and server #21

Closed b-ma closed 1 year ago

b-ma commented 3 years ago

description

We could have:

Even better would be to hide init-qos-browser.js and init-qos-node.js behind the same init-qos.js file, it would not require a major version

examples

node clients

function exitHandler(msg) {
  console.log(msg);
  pd.destroy(); 

  console.log('------------------------- TERM');
  process.kill(process.pid, 'SIGKILL');
}

function initQoS(client) {
  client.socket.addListener('close', () => {
    exitHandler('Disconnected from server');
  });

  process.on('exit', () => exitHandler('none'));
  process.on('uncaughtException', err => exitHandler(err));
  process.on('unhandledRejection', err => exitHandler(err));
}

server

we could at least have something like:

process.on('unhandledRejection', err => exitHandler(err));
b-ma commented 1 year ago

done (even if to be improved) in @soundworks/helpers