kcp2k
kcp2k copied to clipboard
Client Connection Error Callback
Ill duplicate my post with additional details from Mirror's repo.
As i see there is no way to get client connection errors. 2 examples:
Client connection error before client connect to server. Which means connection not even happend. Client Recv: failed to connect to ip=localhost port=7777 reason=System.Net.Sockets.SocketException (0x80004005) As a result game start showing loading screen, got this message at console and runs infinity loading screen because there is no way to catch it exept OnClientDisconnect which i dont need because it not make any sence. Because this method happend every time client disconnect, what i dont need. I need an error, to disable loading screen and show popup to client with error what happend to his game.
Server and client different versions i have server running on previos version, and im trying to connect from new version and i have these warnings on console: id: 29556. This can happen if no handler was registered for this message. NetworkClient: failed to unpack and invoke message. Disconnecting. As a result, i start show loading screen, then i got these warnings, connection not happend and i have infinity loading screen. So i want to catch ANY client connection error and do my stuff, like show error popup or something OnClientError() doest work for it. Idk why, it just never called.
Mr.Gadget says:
These are unrelated issues and should be separate tickets.
Mirror has error events that the transport can raise, but the transport has to raise them. File a ticket with the transport's repo to raise NetworkClient.OnErrorEvent. Then you can override Network Manager's OnClientError(Exception exception).
You need to handle a version check with the server before it gets so far as to have broken handlers. Network Authenticator would be well suited to this.
As i understand form Mr.Gadet answer and my findings of kcp code, there is no call of OnErrorEvent
on transport. And as a result i cant catch errors to run my code. I can use only OnClientDisconnect
but it calls every time when client disconnect what i dont need. Both examples are just examples of client errors that i would like to catch and i can describe a bunch of other errors, but it doesnt metter what kind of errors, its not a point. In other words it would be good to catch ANY client connection error with Network Manager's OnClientError(Exception exception)
.