コード例 #1
0
    private void ClientConnectedOnServer(NetworkMessage message)
    {
        if (!playersManager.CanAddPlayerToGame())
        {
            UIManager.CreateMessage("Client " + message.conn.address + " tried to connect on server but it's full.", MessageColor.RED);
            NetworkServer.SendToClient(message.conn.connectionId, MessageConstants.MESSAGE, new NetworkConsoleMessage()
            {
                message = "Server says: Sorry, server is full. Try again later."
            });
            message.conn.Disconnect();
        }

        NetworkServer.SetClientReady(message.conn);

        UIManager.CreateMessage("Client " + message.conn.address + " connected to your server. Asking his name.", MessageColor.LIGHT_BLUE);

        NetworkServer.SendToClient(message.conn.connectionId, MessageConstants.PLAYER_NAME, new NetworkConsoleMessage()
        {
            message = "Server says: What's your name?"
        });
    }