Esempio n. 1
0
 protected virtual void OnSteamLobbyEnter(SteamLobbyEnterEventArgs e)
 {
     if (this.SteamLobbyEnter != null)
     {
         this.SteamLobbyEnter(this, e);
     }
 }
Esempio n. 2
0
        private void SteamMatchMakingService_SteamLobbyEnter(object sender, SteamLobbyEnterEventArgs e)
        {
            Diagnostics.Log("[Session] Entered the lobby: " + this.SteamMatchMakingService.SteamMatchMaking.GetLobbyData(this.SteamIDLobby, "name"));
            Steamworks.SteamMatchMaking.EChatRoomEnterResponse echatRoomEnterResponse = (Steamworks.SteamMatchMaking.EChatRoomEnterResponse)e.Message.m_EChatRoomEnterResponse;
            if (!Amplitude.Unity.Framework.Application.Preferences.EnableMultiplayer)
            {
                this.OnError(Session.ErrorLevel.Info, "Modding Tools enabled.", (int)e.Message.m_EChatRoomEnterResponse);
                this.Close();
                return;
            }
            string text = this.SteamMatchMakingService.SteamMatchMaking.GetLobbyData(this.SteamIDLobby, "runtimehash");

            if (string.IsNullOrEmpty(text))
            {
                text = "Invalid";
            }
            IRuntimeService service = Services.GetService <IRuntimeService>();

            if (!this.hosting && (service == null || service.Runtime == null || text != service.Runtime.HashKey))
            {
                string text2 = "Invalid";
                if (service != null && service.Runtime != null && !string.IsNullOrEmpty(service.Runtime.HashKey))
                {
                    text2 = service.Runtime.HashKey;
                }
                Diagnostics.LogWarning("ELCP: Hash mismatch: Me: {0}; LobbyDescriptor: {1}", new object[]
                {
                    text2,
                    text
                });
                this.OnError(Session.ErrorLevel.Info, "%JoinGameCheckSumMismatchDescription", (int)e.Message.m_EChatRoomEnterResponse);
                this.Close();
                return;
            }
            if (echatRoomEnterResponse == Steamworks.SteamMatchMaking.EChatRoomEnterResponse.k_EChatRoomEnterResponseSuccess)
            {
                this.OnSessionChange(new SessionChangeEventArgs(SessionChangeAction.Opened, this));
                int lobbyDataCount = this.SteamMatchMakingService.SteamMatchMaking.GetLobbyDataCount(this.SteamIDLobby);
                for (int i = 0; i < lobbyDataCount; i++)
                {
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    if (this.SteamMatchMakingService.SteamMatchMaking.GetLobbyDataByIndex(this.SteamIDLobby, i, out empty, out empty2))
                    {
                        this.SetLobbyData(empty, empty2, true);
                    }
                }
                this.opening = false;
                this.opened  = true;
                if (this.LobbyEnter != null)
                {
                    this.LobbyEnter(this, new LobbyEnterEventArgs(new Steamworks.SteamID(e.Message.m_ulSteamIDLobby)));
                }
                return;
            }
            if (echatRoomEnterResponse != Steamworks.SteamMatchMaking.EChatRoomEnterResponse.k_EChatRoomEnterResponseDoesntExist)
            {
                this.OnError(Session.ErrorLevel.Info, "%SessionErrorCannotJoinLobby", (int)e.Message.m_EChatRoomEnterResponse);
                this.Close();
                return;
            }
            this.OnError(Session.ErrorLevel.Info, "%SessionErrorLobbyDoesNotExist", (int)e.Message.m_EChatRoomEnterResponse);
            this.Close();
        }