- Home /
Server disconnect message after closing connection
Hi all,
I know there is a way to do this but it's eluding me at the moment.
I have a server that accepts incoming player connections. Once it reaches eight players, it closes any new connections that come in. My question is: is there a way to somehow let the player know why their connection was closed by the server?
Here's some code:
void OnPlayerConnected(NetworkPlayer player)
{
//close this connection if the game has already started, or max players are already in the game
if (gameStarted || playerCount >= maxPlayers)
{
//if the game has already started, do not allow the player to create a character and close the connection, setting a message
networkView.RPC("SendServerMessage", player, "Could not connect to game: game has already started!");
Network.CloseConnection(player, true);
return;
}
...}
Essentially, I want to let them now that they are being disconnected for a reason instead of just showing nothing. Obviously, the RPC call isn't working because the connection is getting closed before it finishes sending (I think).
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Best cross platform Http Library? 1 Answer
How to use NetworkManager.ServerChangeScene ? 1 Answer
Network Connection Works Locally, but not Publicly 0 Answers