Beispiel #1
0
    protected void OnSessionRequest(P2PSessionRequest_t pCallback)
    {
        if (lobby.Equals(CSteamID.Nil))
        {
            Debug.Log("User trying to send packet to us, and our lobby doesn't exist!");
            return;
        }
        bool flag = false;

        for (int i = 0; i < SteamMatchmaking.GetNumLobbyMembers(lobby); i++)
        {
            if (SteamMatchmaking.GetLobbyMemberByIndex(lobby, i) == pCallback.m_steamIDRemote)
            {
                flag = true;
            }
        }

        if (flag)
        {
            SteamNetworking.AcceptP2PSessionWithUser(pCallback.m_steamIDRemote);
        }
    }
Beispiel #2
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();
            }
        }