private void OnJoinLobbyMessage(NetworkMessage netMsg) { var playerName = netMsg.ReadMessage <MessageTypes.JoinLobbyMessage>().playerName; playerName = MakeUnique(playerName); int connectionId = netMsg.conn.connectionId; //Debug.Log(String.Format("Adding player {0} with connectionId {1} to lobby", playerName, connectionId)); // create player object, add to list of players in lobby Player player = new Player(playerName, connectionId); _playersInLobby.Add(player); _playerConnections[connectionId] = player; // send the player his unique name var msg = new MessageTypes.PlayerNameMessage(); msg.playerName = playerName; NetworkServer.SendToClient(connectionId, (short)MessageTypes.MessageType.PLAYER_NAME, msg); // send game list to the player ResendLists(); }
private void OnJoinLobbyMessage(NetworkMessage netMsg) { var playerName = netMsg.ReadMessage<MessageTypes.JoinLobbyMessage>().playerName; playerName = MakeUnique(playerName); int connectionId = netMsg.conn.connectionId; //Debug.Log(String.Format("Adding player {0} with connectionId {1} to lobby", playerName, connectionId)); // create player object, add to list of players in lobby Player player = new Player(playerName, connectionId); _playersInLobby.Add(player); _playerConnections[connectionId] = player; // send the player his unique name var msg = new MessageTypes.PlayerNameMessage(); msg.playerName = playerName; NetworkServer.SendToClient(connectionId, (short)MessageTypes.MessageType.PLAYER_NAME, msg); // send game list to the player ResendLists(); }