@aabramychev , NetworkTransport.Disconnect(hostId, connectionid, out error) seems not to remove the host at the end of the function.
And if we removeHost manually after calling it, the resulting things is that the NetworkMessage.disconnect is not send to the server and we have to wait the disconnect time out instead of immediately disconnecting the connection.
The side effect is that if you connect more than 15 time with your application, it throw exceed hosts error…
Is there a workd around ? Is this bug really a bug or it’s supposed to be like this ?
I might not entirely understand your setup, but in my own project if the server (the one that called .addHost) wants to DC itself I call .removehost and then the client gets a disconnect event, no need for disconnect. I assume what you want is for the client to call the server to be disconnected, in that case, you call disconnect from the client, and in the server’s disconnectevent you call removehost.
In fact, if I call Server.Disconnect() and remove the host, the client has to wait the timeout.
If i remove the host later, client get noticed about the server deconnection by a message, and so get disconnected without waiting timeout.
“Send a disconnect signal to the connected peer and close the connection. Poll NetworkTransport.Receive() to be notified that the connection is closed. This signal is only sent once (best effort delivery). If this packet is dropped for some reason, the peer closes the connection by timeout.”
The signal is not send at all if you remove the host immediatly, and the host is not removed if you call Disconnect…
In my code I can write removehost (without calling disconnect) and it can see that the client gets a disconnect event, BUT I agree that if I use Disconnect the client reacts instantly while if I just use removehost it takes a bit before the client calls its disconnect event. IDK why so I cannot help with that.