Ejemplo n.º 1
0
    void SetBasic()
    {
        int Mcount = SteamMatchmaking.GetNumLobbyMembers(Sender.roomid);

        ULS.CreateDs(Mcount);
        for (int i = 0; i < Mcount; i++)
        {
            ULS.UDs[i].GetComponent <UserDetailScript>().HomeWork(SteamMatchmaking.GetLobbyMemberByIndex(Sender.roomid, i));
        }
        PlayersJoined.text = Mcount + " players joined";
        Roomname.text      = SteamMatchmaking.GetLobbyData(Sender.roomid, "name");
        if (SteamMatchmaking.GetLobbyOwner(Sender.roomid) == SteamUser.GetSteamID())
        {
            MPanel.SetActive(true);
        }
        else
        {
            MPanel.SetActive(false);
        }
        DataShowScript[] dss = GetComponentsInChildren <DataShowScript>(DPanel);
        foreach (DataShowScript d in dss)
        {
            d.GetMyData();
        }
        //if (Mcount == 2) GameStart();
    }
Ejemplo n.º 2
0
        private static void OnLobbyCreated(LobbyCreated_t pCallback, bool bIOFailure)
        {
            if (!SteamManager.Initialized)
            {
                Logger.Error("CONNECTION FAILED");
                return;
            }
            if (!bIOFailure)
            {
                Scoreboard.Instance.UpsertScoreboardEntry(Controllers.PlayerController.Instance._playerInfo.playerId, Controllers.PlayerController.Instance._playerInfo.playerName);
                _lobbyInfo.LobbyID    = new CSteamID(pCallback.m_ulSteamIDLobby);
                _lobbyInfo.TotalSlots = SteamMatchmaking.GetLobbyMemberLimit(_lobbyInfo.LobbyID);
                _lobbyInfo.HostName   = GetUserName();
                Logger.Debug($"Lobby has been created");
                var hostUserId = SteamMatchmaking.GetLobbyOwner(_lobbyInfo.LobbyID);
                SteamMatchmaking.SetLobbyData(_lobbyInfo.LobbyID, "version", PACKET_VERSION);

                var me = SteamUser.GetSteamID();
                Connection = ConnectionState.CONNECTED;
                if (hostUserId.m_SteamID == me.m_SteamID)
                {
                    setLobbyStatus("Waiting In Menu");

                    SendLobbyInfo(true);
                }
            }
        }
Ejemplo n.º 3
0
        public bool StartSteamHost(CSteamID steamLobbyId)
        {
            if (steamNetworkingLoopCoroutine != null)
            {
                return(false);
            }

            if (SteamUser.GetSteamID() != SteamMatchmaking.GetLobbyOwner(steamLobbyId))
            {
                Debug.LogError("Cannot be a server if you are not the lobby owner");
                return(false);
            }

            this.steamLobbyId = steamLobbyId;

            steamIdToConnection = new Dictionary <CSteamID, NetworkConnection>(maxConnections);

            connectionIdCounter = 0;

            NetworkServer.dontListen = true;
            StartHost(GetSteamHostTopology().DefaultConfig, steamHostTopology.MaxDefaultConnections);

            steamIdToConnection.Add(SteamUser.GetSteamID(), NetworkServer.localConnections[0]);

            sessionRequestCallback = Callback <P2PSessionRequest_t> .Create(OnSessionRequest);

            sessionErrorCallback = Callback <P2PSessionConnectFail_t> .Create(OnSessionConnectFail);

            steamLobbyChatUpdate = Callback <LobbyChatUpdate_t> .Create(OnLobbyChatUpdate);

            steamNetworkingLoopCoroutine = StartCoroutine(CoSteamNetworkingLoop());
            pingSenderCoroutine          = StartCoroutine(CoPingSender());

            return(true);
        }
Ejemplo n.º 4
0
    void GameStart(int r)
    {
        //NetWriter.rs = r;
        //准备SkillCode交错数组
        Readytoggle.interactable = false;
        SenderSC.PrepareTemp(r, (int)SkillCode.SelfExplodeScript);
        //设置clientNum
        CSteamID tid;

        Sender.TOmb = new CSteamID[r];
        for (int i = 0; i < r; i++)
        {
            tid            = SteamMatchmaking.GetLobbyMemberByIndex(Sender.roomid, i);
            Sender.TOmb[i] = tid;
            if (tid == SteamUser.GetSteamID())
            {
                Sender.clientNum = i;
            }
        }
        SenderPanel.SetActive(true);
        CVS2.SetActive(true);
        SenderSC.SendHello(3);
        if (SteamMatchmaking.GetLobbyOwner(Sender.roomid) == SteamUser.GetSteamID())
        {
            Startbutton.gameObject.SetActive(true);
        }
    }
Ejemplo n.º 5
0
 public void SetLobbyData(string key, string data)
 {
     if (this.m_LobbyId != CSteamID.Nil && SteamMatchmaking.GetLobbyOwner(this.m_LobbyId) == SteamUser.GetSteamID())
     {
         SteamMatchmaking.SetLobbyData(this.m_LobbyId, key, data);
     }
 }
Ejemplo n.º 6
0
    public void SetGameVisibility(P2PGameVisibility visibility)
    {
        switch (visibility)
        {
        case P2PGameVisibility.Public:
            this.m_LobbyVisibility = ELobbyType.k_ELobbyTypePublic;
            break;

        case P2PGameVisibility.Friends:
            this.m_LobbyVisibility = ELobbyType.k_ELobbyTypeFriendsOnly;
            break;

        case P2PGameVisibility.Private:
            this.m_LobbyVisibility = ELobbyType.k_ELobbyTypePrivate;
            break;

        default:
            this.m_LobbyVisibility = ELobbyType.k_ELobbyTypePrivate;
            break;
        }
        if (this.m_LobbyId != CSteamID.Nil && SteamMatchmaking.GetLobbyOwner(this.m_LobbyId) == SteamUser.GetSteamID())
        {
            SteamMatchmaking.SetLobbyType(this.m_LobbyId, this.m_LobbyVisibility);
            SteamMatchmaking.SetLobbyData(this.m_LobbyId, "lobby_type", EnumUtils <P2PGameVisibility> .GetName(visibility));
        }
    }
Ejemplo n.º 7
0
    private IEnumerable <bool> RequestP2PConnectionWithHost()
    {
        while (!SteamManager.Initialized)
        {
            if (P2PLogFilter.logError)
            {
                Debug.LogError("[TransportLayerSteam] SteamManager not initialized");
            }
            yield return(false);
        }
        P2PTransportLayer.CanStartSessionEventArgs canStartSessionEventArgs = new P2PTransportLayer.CanStartSessionEventArgs();
        P2PTransportLayer.CanStartSession(canStartSessionEventArgs);
        if (!canStartSessionEventArgs.IsSessionReady)
        {
            yield return(false);
        }
        CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(this.m_LobbyId);

        if (P2PLogFilter.logInfo)
        {
            Debug.Log("[TransportLayerSteam] Requesting P2P connection (sending empty packet)");
        }
        SteamNetworking.SendP2PPacket(lobbyOwner, null, 0u, EP2PSend.k_EP2PSendReliable, 0);
        this.AssignNewConnectionForUser(lobbyOwner);
        yield break;
        yield break;
    }
Ejemplo n.º 8
0
    void OnLobbyEntered(LobbyEnter_t pCallback)
    {
        if (!SteamManager.Initialized)
        {
            lobbyConnectionState = SessionConnectionState.FAILED;
            return;
        }

        steamLobbyId = new CSteamID(pCallback.m_ulSteamIDLobby);

        Debug.Log("Connected to Steam lobby");
        lobbyConnectionState = SessionConnectionState.CONNECTED;

        var hostUserId = SteamMatchmaking.GetLobbyOwner(steamLobbyId);
        var me         = SteamUser.GetSteamID();

        if (hostUserId.m_SteamID == me.m_SteamID)
        {
            SteamMatchmaking.SetLobbyData(steamLobbyId, "game", GAME_ID);
            UNETServerController.StartUNETServer();
        }
        else
        {
            // joined friend's lobby.
            StartCoroutine(RequestP2PConnectionWithHost());
        }
    }
Ejemplo n.º 9
0
 public static bool IsHost()
 {
     if (_lobbyInfo.LobbyID.m_SteamID == 0 || SteamMatchmaking.GetNumLobbyMembers(_lobbyInfo.LobbyID) == 1)
     {
         return(true);
     }
     return(SteamMatchmaking.GetLobbyOwner(_lobbyInfo.LobbyID).m_SteamID == GetUserID());
 }
Ejemplo n.º 10
0
        public static void OnLobbyEntered(LobbyEnter_t lobby)
        {
            var client = ServiceLocator.Get <IClient>();

            client.Lobby = new CSteamID(lobby.m_ulSteamIDLobby);
            client.Host  = SteamMatchmaking.GetLobbyOwner(new CSteamID(lobby.m_ulSteamIDLobby));
            client.UpdateLobbyInformation();
            LuaContext.FireEvent(LuaConstants.STEAM_LOBBY_ENTERED);
        }
Ejemplo n.º 11
0
    private void OnPlayerLeftLobby(LobbyChatUpdate_t callback)
    {
        var cSteamId = new CSteamID(callback.m_ulSteamIDUserChanged);

        if (cSteamId == SteamMatchmaking.GetLobbyOwner(LobbyId))
        {
            SteamMatchmaking.LeaveLobby(LobbyId);
        }
    }
    public override bool Disconnect()
    {
        CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(new CSteamID(LobbyID));

        SteamMatchmaking.LeaveLobby(new CSteamID(LobbyID));
        HandleDisconnection();
        Connected = false;
        return(SteamNetworking.CloseP2PSessionWithUser(lobbyOwner));
    }
 void OnLobbyEnter(LobbyEnter_t pCallback)
 {
     if (pCallback.m_EChatRoomEnterResponse == (uint)EChatRoomEnterResponse.k_EChatRoomEnterResponseSuccess)
     {
         Connected  = true;
         LobbyOwner = SteamMatchmaking.GetLobbyOwner(new CSteamID(LobbyID));
         SteamNetworking.SendP2PPacket(LobbyOwner, new byte[1], 1, EP2PSend.k_EP2PSendReliable, 0);
     }
 }
Ejemplo n.º 14
0
        public static bool IsLobbyOwner()
        {
            if (SteamCore.InOfflineMode())
            {
                return(true);
            }

            //REMOVE//if ( s_CurrentLobby.m_handle == null ) return false;
            return((CSteamID)SteamUser.GetSteamID() == (CSteamID)SteamMatchmaking.GetLobbyOwner(s_CurrentLobby.m_handle));
        }
Ejemplo n.º 15
0
 public void Set(CSteamID lobbyId)
 {
     //IL_0001: Unknown result type (might be due to invalid IL or missing references)
     //IL_0002: Unknown result type (might be due to invalid IL or missing references)
     //IL_000f: Unknown result type (might be due to invalid IL or missing references)
     //IL_0010: Unknown result type (might be due to invalid IL or missing references)
     //IL_0015: Unknown result type (might be due to invalid IL or missing references)
     Id    = lobbyId;
     State = LobbyState.Active;
     Owner = SteamMatchmaking.GetLobbyOwner(lobbyId);
 }
Ejemplo n.º 16
0
        private void onLobbyDataUpdate(LobbyDataUpdate_t pCallback)
        {
            CSteamID steamLobby = new CSteamID(pCallback.m_ulSteamIDLobby);
            GalaxyID lobbyID    = parseConnectionString(SteamMatchmaking.GetLobbyData(steamLobby, "connect"));

            lobbyOwners[lobbyID.ToUint64()] = SteamMatchmaking.GetLobbyOwner(steamLobby);
            if (lobbyID != null)
            {
                GalaxyInstance.Matchmaking().RequestLobbyData(lobbyID);
            }
        }
Ejemplo n.º 17
0
 private void OnLobbyCreated(LobbyCreated_t result, bool failure)
 {
     if (this.State != LobbyState.Creating)
     {
         return;
     }
     this.State = !failure ? LobbyState.Active : LobbyState.Inactive;
     this.Id    = new CSteamID((ulong)result.m_ulSteamIDLobby);
     this.Owner = SteamMatchmaking.GetLobbyOwner(this.Id);
     this._lobbyCreatedExternalCallback.Invoke(result, failure);
 }
Ejemplo n.º 18
0
 void SetOwner()
 {
     if (lobby.LobbyID != (CSteamID)0)
     {
         CSteamID newOwner = SteamMatchmaking.GetLobbyOwner(lobby.LobbyID);
         if (newOwner != lobby.Owner)
         {
             Host = newOwner;
             lobby.SetOwner(newOwner);
         }
     }
 }
Ejemplo n.º 19
0
 private void UpdateLobby()
 {
     if (!CoopLobby.IsInLobby)
     {
         this.OnBack();
         return;
     }
     if (CoopLobby.Instance == null || CoopLobby.Instance.Info == null || CoopLobby.Instance.Info.Destroyed)
     {
         this.SetErrorText(UiTranslationDatabase.TranslateKey("LOBBY_DESTROYED", "Lobby Destroyed", this._allCapsTexts));
         this.OnBack();
         CoopLobby.LeaveActive();
         return;
     }
     if (!CoopLobby.Instance.Info.IsOwner && CoopLobby.Instance.Info.ServerId.IsValid())
     {
         if (!BoltNetwork.isClient && !base.gameObject.GetComponent <CoopSteamClientStarter>())
         {
             base.gameObject.AddComponent <CoopSteamClientStarter>().gui = this;
             if (GameSetup.IsNewGame)
             {
                 PlaneCrashAudioState.Spawn();
             }
             this.SetLoadingText(UiTranslationDatabase.TranslateKey("STARTING_CLIENT___", "Starting Client...", this._allCapsTexts));
         }
     }
     else
     {
         bool  foundHost = false;
         ulong ownerId   = SteamMatchmaking.GetLobbyOwner(CoopLobby.Instance.Info.LobbyId).m_SteamID;
         this._lobbyScreen._playerCountLabel.text = StringEx.TryFormat(UiTranslationDatabase.TranslateKey("PLAYER_CURRENT_OVER_MAX", "PLAYERS: {0} / {1}", this._allCapsTexts), new object[]
         {
             CoopLobby.Instance.MemberCount,
             CoopLobby.Instance.Info.MemberLimit
         });
         this._lobbyScreen._playerListLabel.text = CoopLobby.Instance.AllMembers.Select(delegate(CSteamID x)
         {
             string text = SteamFriends.GetFriendPersonaName(x);
             bool flag   = x.m_SteamID == ownerId;
             if (flag)
             {
                 text     += " (Host)";
                 foundHost = true;
             }
             return(text);
         }).Aggregate((string a, string b) => a + "\n" + b);
         if (!foundHost)
         {
             this.OnBack();
         }
     }
 }
Ejemplo n.º 20
0
 private static void OnLobbyEntered(LobbyEnter_t result)
 {
     LobbyId   = result.m_ulSteamIDLobby;
     IsInLobby = true;
     Session.Join(SteamMatchmaking.GetLobbyOwner(new CSteamID(LobbyId)));
     if (TMBAW_Game.CurrentGameState != GameState.MainMenu)
     {
         TMBAW_Game.GoToMainMenu();
     }
     MainMenu.CurrentMenuState = MainMenu.MenuState.MultiplayerLobby;
     Console.WriteLine("Entered lobby with id: " + LobbyId);
     OnLobbyChatUpdate(new LobbyChatUpdate_t());
 }
Ejemplo n.º 21
0
        private void onLobbyEnter(LobbyEnter_t pCallback)
        {
            CSteamID lobbyID = new CSteamID(pCallback.m_ulSteamIDLobby);

            if (!(SteamMatchmaking.GetLobbyOwner(lobbyID) == SteamUser.GetSteamID()))
            {
                lobbyRequested = parseConnectionString(SteamMatchmaking.GetLobbyData(lobbyID, "connect"));
                SteamMatchmaking.LeaveLobby(lobbyID);
                if (lobbyRequested != null)
                {
                    Game1.multiplayer.inviteAccepted();
                }
            }
        }
Ejemplo n.º 22
0
 private void onSteamLobbyEnter(LobbyEnter_t pCallback)
 {
     if (pCallback.m_EChatRoomEnterResponse == 1)
     {
         Console.WriteLine("Steam lobby entered: {0}", pCallback.m_ulSteamIDLobby);
         steamLobbyEnterCallback.Unregister();
         steamLobbyEnterCallback = null;
         steamLobby = new CSteamID(pCallback.m_ulSteamIDLobby);
         if (SteamMatchmaking.GetLobbyOwner(steamLobby.Value) == SteamUser.GetSteamID())
         {
             SteamMatchmaking.SetLobbyType(steamLobby.Value, privacyToSteamLobbyType(privacy));
             SteamMatchmaking.SetLobbyData(steamLobby.Value, "connect", getConnectionString());
         }
     }
 }
Ejemplo n.º 23
0
 //------------    When entering lobby (as host or user)    ------------
 private void OnLobbyEntered(LobbyEnter_t entrance)
 {
     _globals.LobbyId = (CSteamID)entrance.m_ulSteamIDLobby;
     if (_globals.PlayingAsHost)
     {
         GD.Print($"OK: Entered into a lobby with ID: {_globals.LobbyId} as host, changing scene.");
         OnLobbyEnteredFinished();
     }
     else
     {
         _globals.HostId = SteamMatchmaking.GetLobbyOwner((CSteamID)entrance.m_ulSteamIDLobby);
         _globals.OwnId  = SteamUser.GetSteamID();
         GD.Print($"OK: Entered into a lobby with ID: {_globals.LobbyId} as user.");
         SendRequestToFillPlayerIds();
     }
 }
Ejemplo n.º 24
0
    private void OnLobbyEnter(LobbyEnter_t callback)
    {
        if (!SteamManager.Initialized)
        {
            return;
        }
        if (this.m_LobbyId != (CSteamID)callback.m_ulSteamIDLobby)
        {
            this.m_LobbyId = new CSteamID(callback.m_ulSteamIDLobby);
        }
        CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(this.m_LobbyId);

        this.m_LobbyOwner = lobbyOwner;
        CSteamID steamID = SteamUser.GetSteamID();

        if (lobbyOwner.m_SteamID == steamID.m_SteamID)
        {
            if (P2PLogFilter.logInfo)
            {
                Debug.Log("[TransportLayerSteam] Connected to Steam lobby as owner");
            }
            SteamMatchmaking.SetLobbyData(this.m_LobbyId, "game_ver", GreenHellGame.s_GameVersion.ToString());
            SteamMatchmaking.SetLobbyData(this.m_LobbyId, "name", SteamFriends.GetPersonaName());
            SteamMatchmaking.SetLobbyMemberData(this.m_LobbyId, "member_name", SteamFriends.GetPersonaName());
            SteamMatchmaking.SetLobbyData(this.m_LobbyId, "lobby_type", EnumUtils <P2PGameVisibility> .GetName(this.GetGameVisibility()));
            P2PTransportLayer.OnLobbyEnter(true);
            return;
        }
        if (callback.m_EChatRoomEnterResponse == 1u)
        {
            if (P2PLogFilter.logInfo)
            {
                Debug.Log(string.Format("[TransportLayerSteam] Connected to Steam lobby {0} as member", this.m_LobbyId));
            }
            this.m_JoiningDelayed = this.RequestP2PConnectionWithHost();
            SteamMatchmaking.SetLobbyMemberData(this.m_LobbyId, "member_name", SteamFriends.GetPersonaName());
            P2PTransportLayer.OnLobbyEnter(false);
            return;
        }
        if (P2PLogFilter.logWarn)
        {
            string str = "[TransportLayerSteam] Lobby enter failure: ";
            EChatRoomEnterResponse echatRoomEnterResponse = (EChatRoomEnterResponse)callback.m_EChatRoomEnterResponse;
            Debug.LogWarning(str + echatRoomEnterResponse.ToString());
        }
        this.Shutdown();
    }
Ejemplo n.º 25
0
 private void OnLobbyCreated(LobbyCreated_t result, bool failure)
 {
     if (State == LobbyState.Creating)
     {
         if (failure)
         {
             State = LobbyState.Inactive;
         }
         else
         {
             State = LobbyState.Active;
         }
         Id    = new CSteamID(result.m_ulSteamIDLobby);
         Owner = SteamMatchmaking.GetLobbyOwner(Id);
         _lobbyCreatedExternalCallback(result, failure);
     }
 }
Ejemplo n.º 26
0
 private void OnLobbyEntered(LobbyEnter_t result, bool failure)
 {
     if (this.State != LobbyState.Connecting)
     {
         return;
     }
     if (!failure)
     {
         this.State = LobbyState.Active;
     }
     else
     {
         this.State = LobbyState.Inactive;
     }
     this.Id    = new CSteamID(result.m_ulSteamIDLobby);
     this.Owner = SteamMatchmaking.GetLobbyOwner(this.Id);
     this._lobbyEnterExternalCallback(result, failure);
 }
Ejemplo n.º 27
0
        void OnLobbyEntered(LobbyEnter_t pCallback)
        {
            Debug.Log("Lobby Joined");
            steamLobbyId = new CSteamID(pCallback.m_ulSteamIDLobby);
            CSteamID hostUserId = SteamMatchmaking.GetLobbyOwner(steamLobbyId);
            CSteamID me         = SteamUser.GetSteamID();

            Debug.Log(hostUserId + " " + me);
            if (hostUserId.Equals(me))
            {
                SteamMatchmaking.SetLobbyData(steamLobbyId, "game", GAME_ID);
                Debug.Log("Set GameID");
            }
            else
            {
                NetworkManager.singleton.networkAddress = hostUserId.m_SteamID.ToString();
                NetworkManager.singleton.StartClient();
            }
        }
    // When a lobby has been entered
    private void OnLobbyEntered(LobbyEnter_t entrance)
    {
        global.global_lobbyID = (CSteamID)entrance.m_ulSteamIDLobby;
        chatField.Editable    = true;

        if (global.playingAsHost)
        {
            lobbyID = (CSteamID)entrance.m_ulSteamIDLobby;
            GD.Print("You just entered lobby " + entrance.m_ulSteamIDLobby + " as host.");
        }
        else if (!global.playingAsHost)
        {
            GD.Print("You just entered lobby " + entrance.m_ulSteamIDLobby);

            // Set global values
            global.player1 = SteamMatchmaking.GetLobbyOwner((CSteamID)entrance.m_ulSteamIDLobby);
            global.player2 = SteamUser.GetSteamID();
        }
    }
    void UpdateLobbyInfo( CSteamID steamIDLobby, ref Lobby outLobby )
    {
        outLobby.m_SteamID = steamIDLobby;
        outLobby.m_Owner = SteamMatchmaking.GetLobbyOwner( steamIDLobby );
        outLobby.m_Members = new LobbyMembers[SteamMatchmaking.GetNumLobbyMembers(steamIDLobby)];
        outLobby.m_MemberLimit = SteamMatchmaking.GetLobbyMemberLimit(steamIDLobby);

        int nDataCount = SteamMatchmaking.GetLobbyDataCount(steamIDLobby);
        outLobby.m_Data = new LobbyMetaData[nDataCount];
        for (int i = 0; i < nDataCount; ++i)
        {
            bool lobbyDataRet = SteamMatchmaking.GetLobbyDataByIndex(steamIDLobby, i, out outLobby.m_Data[i].m_Key, Constants.k_nMaxLobbyKeyLength, out outLobby.m_Data[i].m_Value, Constants.k_cubChatMetadataMax);
            if (!lobbyDataRet)
            {
                Debug.LogError("SteamMatchmaking.GetLobbyDataByIndex returned false.");
                continue;
            }

        }
    }
Ejemplo n.º 30
0
    protected void RegisterWithProvider()
    {
        networkUIController.SetUIMode(UIMode.Connecting);

        //Create a PlayerJoin packet, which the provider will use as a trigger to
        //register a new player. It will update its internal database, and will
        //distribute this info as a normal DatabaseUpdate.
        MeshPacket p = new MeshPacket(new byte[0],
                                      PacketType.PlayerJoin,
                                      SteamUser.GetSteamID().m_SteamID,
                                      SteamMatchmaking.GetLobbyOwner(lobby).m_SteamID,
                                      (byte)ReservedObjectIDs.Unspecified,
                                      (byte)ReservedObjectIDs.DatabaseObject,
                                      (byte)ReservedSubcomponentIDs.Unspecified);

        p.qos = EP2PSend.k_EP2PSendReliable;
        RoutePacketDirect(p, p.GetTargetPlayerId());
        //Soon, we will receive a DatabaseUpdate with all of the up to date database information,
        //including our own player object!
    }