Hxbit client-side disconnect handling

Hi,

I’m trying out heaps with hxbit for a little multiplayer game project and am currently unable to find a way for handling sudden server disconnects on the client side, e.g. when I close the server window while the client is still connected.

More specifically, I don’t see a way for catching the following exception, since it is thrown inside the library code during the main loop:

Connection closed

Called from hxd.net.SocketHost.~connect.0 (hxd/net/SocketHost.hx line 99)
Called from hxd.net.HLSocketInput.onData (hxd/net/Socket.hx line 331)
Called from hl.uv._Loop.$Loop_Impl_.~getDefault.0 (C:\HaxeToolkit\haxe\std/hl/uv/Loop.hx line 51)
Called from haxe.$MainLoop.tick (C:\HaxeToolkit\haxe\std/haxe/MainLoop.hx line 204)
Called from haxe.$MainLoop.~injectIntoEventLoop.0 (C:\HaxeToolkit\haxe\std/haxe/MainLoop.hx line 118)
Called from sys.thread.EventLoop.progress (C:\HaxeToolkit\haxe\std/sys/thread/EventLoop.hx line 114)
Called from hxd.$System.runMainLoop (hxd/System.hl.hx line 152)
Called from hxd.$System.runMainLoop (hxd/System.hl.hx line 142)
Called from haxe.$Timer.~delay.0 (C:\HaxeToolkit\haxe\std/haxe/Timer.hx line 144)
Called from haxe.$Timer.~__constructor__.0 (C:\HaxeToolkit\haxe\std/haxe/Timer.hx line 76)
Called from sys.thread.EventLoop.loop (C:\HaxeToolkit\haxe\std/sys/thread/EventLoop.hx line 150)
Called from sys.thread._Thread.$Thread_Impl_.processEvents (C:\HaxeToolkit\haxe\std/hl/_std/sys/thread/Thread.hx line 62)

I can’t seem to find any suitable callbacks on NetworkingClient or NetworkingHost besides ‘onUnregister’, but that doesn’t seem to be called at all in this scenario. hxd.System does not provide any error-handling callbacks for the main loop either.

Do I need to manually send an RPC to all clients when the server is shutting down to make them terminate the connection cleanly or is there some other intended way to gracefully handle disconnect events?
In the case of a sudden internet failure, I would not even be able to send an RPC, so I don’t feel like this would be the way to go.

welcome to the boards!

and as you can see, it’s kinda dead. :cry:

for something as specific or complex as this, i’d suggest you join the discord server channel and leave a message there, as the tech gurus are often there lurking about