hapijs / nes

WebSocket adapter plugin for hapi routes
Other
503 stars 87 forks source link

Request: asynchronous onConnection/onDisconnection #158

Closed andrezzoid closed 8 years ago

andrezzoid commented 8 years ago

Would be great if plugin options onConnection and onDisconnection could have callbacks, for instance, if one needs to make a database read/write on each socket connection.

mtharrison commented 8 years ago

Those options already take a function.

onConnection - a function with the signature function(socket) invoked for each incoming client connection where:

  • socket - the Socket object of the incoming connection. onDisconnection - a function with the signature function(socket) invoked for each incoming client connection on disconnect where:
  • socket - the Socket object of the connection.
andrezzoid commented 8 years ago

I know that. I was suggesting they could have a callback, like function(socket, callback) in case you needed to acess the DB or any other kind of long operation for each socket connection.

hueniverse commented 8 years ago

It should not matter if you need to make async calls because you are not returning a value here. It's not like if you delayed the callback from returning it will have any impact. This is an event, not an interaction.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.