protected override void Internal_OnGameReady() { _localPlayerInfo.IsMaster = false; _localPlayerInfo.PlayerId = PlayerId.Invalid; // Say hello to server ! (this should initiate the process of being added to valid players) NetMessageClientHello helloMessage = new NetMessageClientHello() { playerName = _localPlayerInfo.PlayerName }; _clientSession.SendNetMessageToServer(helloMessage); Log.Info("[PlayerRepertoireClient] Hello sent"); }
void OnClientHello(NetMessageClientHello message, INetworkInterfaceConnection clientConnection) { Log.Info("[PlayerRepertoireServer] OnClientHello"); int index = _newConnectionsNotYetPlayers.IndexOf(clientConnection); if (index == -1) { Log.Warning("[PlayerRepertoireServer] We received a client hello, but the client is not in the _newConnectionsNotYetPlayers list. The hello will be ignored."); return; } _newConnectionsNotYetPlayers.RemoveAt(index); // Add new player to list PlayerInfo newPlayerInfo = CreateNewPlayer(message.playerName, false); // Notify other players NetMessagePlayerJoined playerJoinedMessage = new NetMessagePlayerJoined { playerInfo = newPlayerInfo }; _serverSession.SendNetMessage(playerJoinedMessage, _playerConnections); Log.Info("[PlayerRepertoireServer] sent NetMessagePlayerJoined"); // add new connection _playerConnections.Add(clientConnection); // Assign id to the new player NetMessagePlayerIdAssignment playerIdAssignementMessage = new NetMessagePlayerIdAssignment { playerId = newPlayerInfo.PlayerId }; _serverSession.SendNetMessage(playerIdAssignementMessage, clientConnection); Log.Info("[PlayerRepertoireServer] sent NetMessagePlayerIdAssignment"); // Send the complete player list to the new player NetMessagePlayerRepertoireSync syncMessage = new NetMessagePlayerRepertoireSync() { players = _players.ToArray() }; _serverSession.SendNetMessage(syncMessage, clientConnection); Log.Info("[PlayerRepertoireServer] sent NetMessagePlayerRepertoireSync"); }