Exemple #1
0
 internal static void InstallEvents()
 {
     P2PSessionRequest_t.Install((P2PSessionRequest_t x) => {
         Action <SteamId> onP2PSessionRequest = SteamNetworking.OnP2PSessionRequest;
         if (onP2PSessionRequest != null)
         {
             onP2PSessionRequest(x.SteamIDRemote);
         }
         else
         {
         }
     }, false);
     P2PSessionConnectFail_t.Install((P2PSessionConnectFail_t x) => {
         Action <SteamId> onP2PConnectionFailed = SteamNetworking.OnP2PConnectionFailed;
         if (onP2PConnectionFailed != null)
         {
             onP2PConnectionFailed(x.SteamIDRemote);
         }
         else
         {
         }
     }, false);
 }
	void OnP2PSessionRequest(P2PSessionRequest_t pCallback) {
		Debug.Log("[" + P2PSessionRequest_t.k_iCallback + " - P2PSessionRequest] - " + pCallback.m_steamIDRemote);

		bool ret = SteamNetworking.AcceptP2PSessionWithUser(pCallback.m_steamIDRemote);
		print("SteamNetworking.AcceptP2PSessionWithUser(" + pCallback.m_steamIDRemote + ") - " + ret);

		m_RemoteSteamId = pCallback.m_steamIDRemote;
	}
 internal static void InstallEvents()
 {
     P2PSessionRequest_t.Install(x => OnP2PSessionRequest?.Invoke(x.SteamIDRemote));
     P2PSessionConnectFail_t.Install(x => OnP2PConnectionFailed?.Invoke(x.SteamIDRemote));
 }
Exemple #4
0
 void OnP2PSessionRequest(P2PSessionRequest_t request)
 {
     Debug.Log("OnP2PSessionRequest from "+request.m_steamIDRemote);
     SteamNetworking.AcceptP2PSessionWithUser(request.m_steamIDRemote);
 }
	//-----------------------------------------------------------------------------
	// Purpose: Handle clients connecting
	//-----------------------------------------------------------------------------
	void OnP2PSessionRequest(P2PSessionRequest_t pCallback) {
		Debug.Log("OnP2PSesssionRequest Called steamIDRemote: " + pCallback.m_steamIDRemote); // Riley

		// we'll accept a connection from anyone
		SteamGameServerNetworking.AcceptP2PSessionWithUser(pCallback.m_steamIDRemote);
	}
Exemple #6
0
        void OnP2PSessionRequest(P2PSessionRequest_t callback)
        {
            // For now always allow connections, without a kick for being banned.

            Debug.Log("Hey we got someone!");

            if (SteamGameServerNetworking.AcceptP2PSessionWithUser(callback.m_steamIDRemote))
            {
                _Players.Add(callback.m_steamIDRemote, EPlayerStatus.Pending);

                // Now we need a ticket validation response from the client.
                // Have the Client Call SteamUser.RequestEncryptedAppTicket()

                if(PlayerConnect != null)
                    PlayerConnect(callback.m_steamIDRemote); // Calls even if the player is not verified.
            }
        }
 private bool OnPacketRead(byte[] data, int length, CSteamID userId)
 {
     P2PSessionRequest_t p2PSessionRequestT = new P2PSessionRequest_t();
     if (!this._connectionStateMap.ContainsKey(userId) || this._connectionStateMap[userId] == NetSocialModule.ConnectionState.Inactive)
     {
         p2PSessionRequestT.m_steamIDRemote = userId;
         this.OnP2PSessionRequest(p2PSessionRequestT);
         if (!this._connectionStateMap.ContainsKey(userId) || this._connectionStateMap[userId] == NetSocialModule.ConnectionState.Inactive)
         {
             return false;
         }
     }
     NetSocialModule.ConnectionState item = this._connectionStateMap[userId];
     if (item != NetSocialModule.ConnectionState.Authenticating)
     {
         return item == NetSocialModule.ConnectionState.Connected;
     }
     if (length < 3)
     {
         return false;
     }
     if ((data[1] << 8 | data[0]) != length)
     {
         return false;
     }
     if (data[2] != 93)
     {
         return false;
     }
     byte[] numArray = new byte[(int)data.Length - 3];
     Array.Copy(data, 3, numArray, 0, (int)numArray.Length);
     switch (SteamUser.BeginAuthSession(numArray, (int)numArray.Length, userId))
     {
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultOK:
         {
             this._connectionStateMap[userId] = NetSocialModule.ConnectionState.Connected;
             this.BroadcastConnectedUsers();
             break;
         }
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultInvalidTicket:
         {
             this.Close(userId);
             break;
         }
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultDuplicateRequest:
         {
             this.Close(userId);
             break;
         }
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultInvalidVersion:
         {
             this.Close(userId);
             break;
         }
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultGameMismatch:
         {
             this.Close(userId);
             break;
         }
         case EBeginAuthSessionResult.k_EBeginAuthSessionResultExpiredTicket:
         {
             this.Close(userId);
             break;
         }
     }
     return false;
 }
 private void OnP2PSessionRequest(P2PSessionRequest_t result)
 {
     P2PSessionState_t p2PSessionStateT;
     CSteamID mSteamIDRemote = result.m_steamIDRemote;
     if (this._connectionStateMap.ContainsKey(mSteamIDRemote) && this._connectionStateMap[mSteamIDRemote] != NetSocialModule.ConnectionState.Inactive)
     {
         SteamNetworking.AcceptP2PSessionWithUser(mSteamIDRemote);
         return;
     }
     if (!this._acceptingClients)
     {
         return;
     }
     SteamNetworking.AcceptP2PSessionWithUser(mSteamIDRemote);
     while (SteamNetworking.GetP2PSessionState(mSteamIDRemote, out p2PSessionStateT) && p2PSessionStateT.m_bConnecting == 1)
     {
     }
     if (p2PSessionStateT.m_bConnectionActive == 0)
     {
         this.Close(mSteamIDRemote);
     }
     this._connectionStateMap[mSteamIDRemote] = NetSocialModule.ConnectionState.Authenticating;
     this._connectionAcceptedCallback(new SocialSocket(new SteamAddress(mSteamIDRemote)));
 }
		private void OnP2PSessionRequest(P2PSessionRequest_t result)
		{
			CSteamID steamIDRemote = result.m_steamIDRemote;
			if (this._connectionStateMap.ContainsKey(steamIDRemote) && this._connectionStateMap[steamIDRemote] != NetSocialModule.ConnectionState.Inactive)
			{
				SteamNetworking.AcceptP2PSessionWithUser(steamIDRemote);
				return;
			}
			if (!this._acceptingClients)
			{
				return;
			}
			if (!this._mode.HasFlag(ServerMode.FriendsOfFriends) && SteamFriends.GetFriendRelationship(steamIDRemote) != EFriendRelationship.k_EFriendRelationshipFriend)
			{
				return;
			}
			SteamNetworking.AcceptP2PSessionWithUser(steamIDRemote);
			P2PSessionState_t p2PSessionState_t;
			while (SteamNetworking.GetP2PSessionState(steamIDRemote, out p2PSessionState_t) && p2PSessionState_t.m_bConnecting == 1)
			{
			}
			if (p2PSessionState_t.m_bConnectionActive == 0)
			{
				this.Close(steamIDRemote);
			}
			this._connectionStateMap[steamIDRemote] = NetSocialModule.ConnectionState.Authenticating;
			this._connectionAcceptedCallback(new SocialSocket(new SteamAddress(steamIDRemote)));
		}
 private static void P2PSessionRequest(P2PSessionRequest_t param)
 {
     Debug.Log("CoopSteamManager.P2PSessionRequest (client): remoteId=" + param.m_steamIDRemote);
     SteamNetworking.AcceptP2PSessionWithUser(param.m_steamIDRemote);
 }
		private void OnP2PSessionRequest(P2PSessionRequest_t result)
		{
			CSteamID steamIDRemote = result.m_steamIDRemote;
			if (this._connectionStateMap.ContainsKey(steamIDRemote) && this._connectionStateMap[steamIDRemote] != NetSocialModule.ConnectionState.Inactive)
			{
				SteamNetworking.AcceptP2PSessionWithUser(steamIDRemote);
			}
		}