botmasterai / botmaster-socket.io

The socket.io Botmaster integration
MIT License
8 stars 8 forks source link

Closing client connection from server side (request NOT bug) #10

Closed willemevenwel closed 6 years ago

willemevenwel commented 6 years ago

Hi,

How would I go about closing a connection from the server side. For instance, when I see a client has not sent any event or message to the server for more than a minute.

Please assist kindly,

Regards,

Willem

jdwuarin commented 6 years ago

Hi,

As mentioned in issue: https://github.com/botmasterai/botmaster-socket.io/issues/9

The socket.io server is exposed via: bot.ioServer. Disconnecting can thus be done using that object.

You would need to catch the socket connections by listening for connection events and then when you consider it time to disconnect them, do so. Check out the socket.io Api for more:

https://socket.io/docs/server-api/#socket-disconnect-close