private void MessageReceiver_FMD_L_SERVERS_LIST(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_L_SERVERS_LIST message) { Log("FM_L_SERVERS_LIST_OnEvent:"); AllegianceInterop.ServerCoreInfo_Managed targetServer = null; foreach (var server in message.Servers) { Log("\t" + server.szName + ":" + server.szRemoteAddress); if (Configuration.ServerName.Equals(server.szName, StringComparison.InvariantCultureIgnoreCase) == true) { targetServer = server; } } //AllegianceInterop.StaticCoreInfo_Managed targetCore = null; foreach (var core in message.Cores) { Log("\t" + "Core: " + core.cbIGCFile); //if (targetCore.cbIGCFile == CoreName) // targetCore = core; } if (_isClientConnectedToServer == false) { if (IsGameController == true && _hasCreatedGame == false && targetServer != null && (targetServer.iCurGames == 0 || targetServer.iCurGames == _receivedMissionCount)) { _hasCreatedGame = true; // Create a game on the first server found. AllegianceInterop.FMD_C_CREATE_MISSION_REQ req = new AllegianceInterop.FMD_C_CREATE_MISSION_REQ(targetServer.szName, targetServer.szRemoteAddress, CoreName, GameName); client.SendMessageLobby(req); } else if (targetServer != null) { _waitingForMissionCount += targetServer.iCurGames; Log($"Waiting for mission details from Lobby for {targetServer.iCurGames} missions. IsGameController: {IsGameController}, _hasCreatedGame: {_hasCreatedGame}, targetServer: {targetServer}, _waitingForMissionCount: {_waitingForMissionCount}, _receivedMissionCount: {_receivedMissionCount}"); } else { Log("No servers currently attached to the lobby, waiting for a server to join."); } } }
private void MessageReceiver_FMD_LS_LOBBYMISSIONINFO(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_LS_LOBBYMISSIONINFO message) { Log($"Got mission info for game: {message.szGameName}, server address: {message.szServerAddr}, server port: {message.dwPort}, mission cookie: {message.dwCookie}"); //switch (_serverType) //{ // case ServerType.Lobby: if (_isClientConnectedToServer == false && message.szGameName == GameName) { _isClientConnectedToServer = true; // Once the client connects to the server, the FM_S_LOGONACK response will trigger the disconnect from the lobby. client.ConnectToServer(message.szServerAddr, (int)message.dwPort, PlayerName, BotAuthenticationGuid, (int)message.dwCookie); } _receivedMissionCount++; _waitingForMissionCount--; // No more mission details are coming, and we didn't find a bot game, so create a new one. if (_waitingForMissionCount == 0 && _isClientConnectedToServer == false) { _hasCreatedGame = true; AllegianceInterop.FMD_C_CREATE_MISSION_REQ req = new AllegianceInterop.FMD_C_CREATE_MISSION_REQ(message.szServerName, message.szServerAddr, CoreName, GameName); client.SendMessageLobby(req); } // break; // case ServerType.Server: // Log("Ready to join mission."); // break; // default: // throw new NotSupportedException(_serverType.ToString()); //} }
private void MessageReceiver_FMD_LS_LOBBYMISSIONINFO_Old(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_LS_LOBBYMISSIONINFO message) { Log($"Got mission info for game: {message.szGameName}, server address: {message.szServerAddr}, server port: {message.dwPort}, mission cookie: {message.dwCookie}"); //switch (_serverType) //{ // case ServerType.Lobby: if (_isClientConnectedToServer == false && message.szGameName == GameName) { _isClientConnectedToServer = true; Log("Connecting to game, waiting for FM_S_LOGONACK from server."); bool connected = false; while (connected == false && _cancellationTokenSource.IsCancellationRequested == false) { // Once the client connects to the server, the FM_S_LOGONACK response will trigger the disconnect from the lobby. if (client.ConnectToServer(message.szServerAddr, (int)message.dwPort, PlayerName, BotAuthenticationGuid, (int)message.dwCookie) == true) { connected = true; break; } Log("\tCouldn't connect, retrying."); Thread.Sleep(100); } //Task.Run(() => //{ // bool connected = false; // while(connected == false && _cancellationTokenSource.IsCancellationRequested == false) // { // // Once the client connects to the server, the FM_S_LOGONACK response will trigger the disconnect from the lobby. // if (ClientConnection.ConnectToServer(message.szServerAddr, (int)message.dwPort, PlayerName, BotAuthenticationGuid, (int)message.dwCookie) == true) // { // connected = true; // break; // } // Log("\tCouldn't connect, retrying."); // Thread.Sleep(100); // } //}); } _receivedMissionCount++; _waitingForMissionCount--; // No more mission details are coming, and we didn't find a bot game, so create a new one. if (_waitingForMissionCount == 0 && _isClientConnectedToServer == false) { _hasCreatedGame = true; AllegianceInterop.FMD_C_CREATE_MISSION_REQ req = new AllegianceInterop.FMD_C_CREATE_MISSION_REQ(message.szServerName, message.szServerAddr, CoreName, GameName); client.SendMessageLobby(req); } // break; // case ServerType.Server: // Log("Ready to join mission."); // break; // default: // throw new NotSupportedException(_serverType.ToString()); //} }
private void MessageReceiver_FMD_LS_LOBBYMISSIONINFO(AllegianceInterop.ClientConnection client, AllegianceInterop.FMD_LS_LOBBYMISSIONINFO message) { Log($"Got mission info for game: {message.szGameName}, server address: {message.szServerAddr}, server port: {message.dwPort}, mission cookie: {message.dwCookie}"); //switch (_serverType) //{ // case ServerType.Lobby: if (_isClientConnectedToServer == false && message.szGameName == GameName) { _isClientConnectedToServer = true; Log("Connecting to game, waiting for FM_S_LOGONACK from server."); AllegianceInterop.FMD_C_JOIN_GAME_REQ joinGame = new AllegianceInterop.FMD_C_JOIN_GAME_REQ(message.dwCookie); client.SendMessageLobby(joinGame); //bool connected = false; //while (connected == false && _cancellationTokenSource.IsCancellationRequested == false) //{ // // Once the client connects to the server, the FM_S_LOGONACK response will trigger the disconnect from the lobby. // if (client.ConnectToServer(message.szServerAddr, (int)message.dwPort, PlayerName, BotAuthenticationGuid, (int)message.dwCookie) == true) // { // connected = true; // break; // } // Log("\tCouldn't connect, retrying."); // Thread.Sleep(100); //} //Task.Run(() => //{ // bool connected = false; // while(connected == false && _cancellationTokenSource.IsCancellationRequested == false) // { // // Once the client connects to the server, the FM_S_LOGONACK response will trigger the disconnect from the lobby. // if (ClientConnection.ConnectToServer(message.szServerAddr, (int)message.dwPort, PlayerName, BotAuthenticationGuid, (int)message.dwCookie) == true) // { // connected = true; // break; // } // Log("\tCouldn't connect, retrying."); // Thread.Sleep(100); // } //}); } if (Configuration.ServerName.Equals(message.szServerName, StringComparison.InvariantCultureIgnoreCase) == true) { _receivedMissionCount++; _waitingForMissionCount--; // No more mission details are coming, and we didn't find a bot game, so create a new one. if (_waitingForMissionCount == 0 && _isClientConnectedToServer == false) { Log($"MessageReceiver_FMD_LS_LOBBYMISSIONINFO(): Creating game. message.szServerName: {message.szServerName}, message.szServerAddr: {message.szServerAddr}, CoreName: {CoreName}, GameName: {GameName}"); _hasCreatedGame = true; AllegianceInterop.FMD_C_CREATE_MISSION_REQ req = new AllegianceInterop.FMD_C_CREATE_MISSION_REQ(message.szServerName, message.szServerAddr, CoreName, GameName); client.SendMessageLobby(req); } } }