コード例 #1
0
 public override void Update()
 {
     if (DuckNetwork.status == DuckNetStatus.Disconnected && !this._attemptedConnection)
     {
         this._startedJoining = true;
         if (Profiles.active.Count == 0)
         {
             Profiles.DefaultPlayer1.team = Teams.Player1;
         }
         TeamSelect2.FillMatchmakingProfiles();
         if (this._lobbyID == 0UL)
         {
             DuckNetwork.Join("duckGameServer");
         }
         else
         {
             DuckNetwork.Join(this._lobbyID.ToString());
         }
         this._attemptedConnection = true;
     }
     else if (DuckNetwork.status == DuckNetStatus.Disconnected && this._attemptedConnection)
     {
         Level.current = (Level) new ConnectionError("|RED|CONNECTION FAILED!");
     }
     base.Update();
 }
コード例 #2
0
 public void OnSessionEnded(DuckNetErrorInfo error)
 {
     if (!this.open)
     {
         return;
     }
     if (UIMatchmakingBox._state == MatchmakingState.Disconnect)
     {
         if (this._tryHostingLobby != null)
         {
             this._tries = 0;
         }
         this._tryHostingLobby = (Lobby)null;
         if (this._quit)
         {
             HUD.CloseAllCorners();
             this.Close();
             this._openOnClose.Open();
         }
         else if (this._tryConnectLobby != null)
         {
             DuckNetwork.Join(this._tryConnectLobby.id.ToString());
             this.ChangeState(MatchmakingState.Connecting);
         }
         else
         {
             this.ChangeState(MatchmakingState.SearchForLobbies);
         }
     }
     else
     {
         if (error != null)
         {
             if (error.error == DuckNetError.VersionMismatch)
             {
                 if (error.tooNew)
                 {
                     this._newStatusList.Add("|DGRED|Their version was older.");
                 }
                 else
                 {
                     this._newStatusList.Add("|DGRED|Their version was newer.");
                 }
                 if (this._tryConnectLobby != null)
                 {
                     this._permenantBlacklist.Add(new BlacklistServer()
                     {
                         lobby    = this._tryConnectLobby.id,
                         cooldown = 15f
                     });
                 }
             }
             else if (error.error == DuckNetError.FullServer)
             {
                 this._newStatusList.Add("|DGRED|Failed (FULL SERVER)");
             }
             else if (error.error == DuckNetError.ConnectionTimeout)
             {
                 this._newStatusList.Add("|DGRED|Failed (TIMEOUT)");
             }
             else if (error.error == DuckNetError.GameInProgress)
             {
                 this._newStatusList.Add("|DGRED|Failed (IN PROGRESS)");
             }
             else
             {
                 this._newStatusList.Add("|DGRED|Unknown connection error.");
                 if (this._tryConnectLobby != null)
                 {
                     this._permenantBlacklist.Add(new BlacklistServer()
                     {
                         lobby    = this._tryConnectLobby.id,
                         cooldown = 15f
                     });
                 }
             }
         }
         else
         {
             this._newStatusList.Add("|DGRED|Connection timeout.");
             if (this._tryConnectLobby != null)
             {
                 this._permenantBlacklist.Add(new BlacklistServer()
                 {
                     lobby    = this._tryConnectLobby.id,
                     cooldown = 15f
                 });
             }
         }
         if (this._tryConnectLobby != null)
         {
             this._failedAttempts.Add(new BlacklistServer()
             {
                 lobby    = this._tryConnectLobby.id,
                 cooldown = 15f
             });
         }
         DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Connection failure, continuing search.", Color.White);
         this._tryConnectLobby = (Lobby)null;
         this.ChangeState(MatchmakingState.SearchForLobbies);
     }
 }