예제 #1
0
 public unsafe static void CloseConnection(User who)
 {
     if (!_initialized)
     {
         return;
     }
     SteamNetworking.CloseP2PSessionWithUser(new CSteamID(who.id));
 }
예제 #2
0
 protected void CloseP2PSessionWithUser(CSteamID clientSteamID)
 {
     if (!SteamManager.Initialized)
     {
         throw new ObjectDisposedException("Steamworks");
     }
     SteamNetworking.CloseP2PSessionWithUser(clientSteamID);
 }
예제 #3
0
        protected void CloseP2PSessionWithUser(CSteamID clientSteamID)
        {
#if UNITY_SERVER
            SteamGameServerNetworking.CloseP2PSessionWithUser(clientSteamID);
#else
            SteamNetworking.CloseP2PSessionWithUser(clientSteamID);
#endif
        }
예제 #4
0
 protected void CloseP2PSessionWithUser(SteamId clientSteamID)
 {
     if (!Steamworks.SteamClient.IsValid)
     {
         throw new ObjectDisposedException("Steamworks");
     }
     SteamNetworking.CloseP2PSessionWithUser(clientSteamID);
 }
예제 #5
0
        private void OnLobbyEntered(LobbyEnter_t result, bool failure)
        {
            //IL_001e: Unknown result type (might be due to invalid IL or missing references)
            //IL_002c: Unknown result type (might be due to invalid IL or missing references)
            //IL_0082: Unknown result type (might be due to invalid IL or missing references)
            //IL_0094: Unknown result type (might be due to invalid IL or missing references)
            //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b2: Unknown result type (might be due to invalid IL or missing references)
            //IL_00ca: Unknown result type (might be due to invalid IL or missing references)
            //IL_00db: Unknown result type (might be due to invalid IL or missing references)
            //IL_0127: Unknown result type (might be due to invalid IL or missing references)
            WeGameHelper.WriteDebugString(" OnLobbyEntered");
            SteamNetworking.AllowP2PPacketRelay(true);
            SendAuthTicket(_lobby.Owner);
            int num = 0;
            P2PSessionState_t val = default(P2PSessionState_t);

            while (SteamNetworking.GetP2PSessionState(_lobby.Owner, ref val) && val.m_bConnectionActive != 1)
            {
                switch (val.m_eP2PSessionError)
                {
                case 2:
                    ClearAuthTicket();
                    return;

                case 1:
                    ClearAuthTicket();
                    return;

                case 3:
                    ClearAuthTicket();
                    return;

                case 5:
                    ClearAuthTicket();
                    return;

                case 4:
                    if (++num > 5)
                    {
                        ClearAuthTicket();
                        return;
                    }
                    SteamNetworking.CloseP2PSessionWithUser(_lobby.Owner);
                    SendAuthTicket(_lobby.Owner);
                    break;
                }
            }
            _connectionStateMap[_lobby.Owner] = ConnectionState.Connected;
            SteamFriends.SetPlayedWith(_lobby.Owner);
            SteamFriends.SetRichPresence("status", Language.GetTextValue("Social.StatusInGame"));
            Main.clrInput();
            Netplay.ServerPassword = "";
            Main.GetInputText("");
            Main.autoPass = false;
            Main.netMode  = 1;
            Netplay.OnConnectedToSocialServer(new SocialSocket(new SteamAddress(_lobby.Owner)));
        }
    public override bool Disconnect()
    {
        CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(new CSteamID(LobbyID));

        SteamMatchmaking.LeaveLobby(new CSteamID(LobbyID));
        HandleDisconnection();
        Connected = false;
        return(SteamNetworking.CloseP2PSessionWithUser(lobbyOwner));
    }
 public void Stop()
 {
     SteamNetworking.CloseP2PSessionWithUser(NetClient.instanceClient.serversSteamID);
     //if(client == null)
     //{
     //    return;
     //}
     //client.Dispose();
 }
예제 #8
0
        async Task WaitAndClose(CSteamID remote)
        {
            await Task.Delay(2000);

            if (SteamManager.Initialized)
            {
                SteamNetworking.CloseP2PSessionWithUser(remote);
                Debug.Log($"SteamConnection Closed {remote}");
            }
        }
예제 #9
0
 private void Close(CSteamID user)
 {
     if (!this._connectionStateMap.ContainsKey(user))
     {
         return;
     }
     SteamUser.EndAuthSession(user);
     SteamNetworking.CloseP2PSessionWithUser(user);
     this._connectionStateMap[user] = NetSocialModule.ConnectionState.Inactive;
 }
        private void OnLobbyEntered(LobbyEnter_t result, bool failure)
        {
            SteamNetworking.AllowP2PPacketRelay(true);
            this.SendAuthTicket(this._lobby.Owner);
            var num = 0;
            P2PSessionState_t p2PsessionStateT;

            while (SteamNetworking.GetP2PSessionState(this._lobby.Owner, out p2PsessionStateT) &&
                   p2PsessionStateT.m_bConnectionActive != 1)
            {
                switch ((byte)p2PsessionStateT.m_eP2PSessionError)
                {
                case 1:
                    this.ClearAuthTicket();
                    return;

                case 2:
                    this.ClearAuthTicket();
                    return;

                case 3:
                    this.ClearAuthTicket();
                    return;

                case 4:
                    if (++num > 5)
                    {
                        this.ClearAuthTicket();
                        return;
                    }

                    SteamNetworking.CloseP2PSessionWithUser(this._lobby.Owner);
                    this.SendAuthTicket(this._lobby.Owner);
                    continue;

                case 5:
                    this.ClearAuthTicket();
                    return;

                default:
                    continue;
                }
            }

            this._connectionStateMap[this._lobby.Owner] = NetSocialModule.ConnectionState.Connected;
            SteamFriends.SetPlayedWith(this._lobby.Owner);
            SteamFriends.SetRichPresence("status", Language.GetTextValue("Social.StatusInGame"));
            Main.clrInput();
            Netplay.ServerPassword = "";
            Main.GetInputText("");
            Main.autoPass = false;
            Main.netMode  = 1;
            Netplay.OnConnectedToSocialServer(
                (ISocket) new SocialSocket((RemoteAddress) new SteamAddress(this._lobby.Owner)));
        }
        /**
         * This closes the P2P connection and if its connected or connecting adds it to a queue to return the disconnect event
         */
        private void closeSteamConnection(SteamClient steamClient)
        {
            if (steamClient.state == SteamClient.ConnectionState.CONNECTED || steamClient.state == SteamClient.ConnectionState.CONNECTING)
            {
                steamClient.state = SteamClient.ConnectionState.DISCONNECTING;

                steamDisconnectedConnections.Enqueue(steamClient);
            }

            SteamNetworking.CloseP2PSessionWithUser(steamClient.steamID);
        }
예제 #12
0
        public override void disconnect()
        {
            if (friend == null)
            {
                return;
            }

            Log.trace("Closed P2P session with " + friend.displayName);
            SteamNetworking.CloseP2PSessionWithUser(new CSteamID(friend.id));
            friend = null;
        }
 private void Close(CSteamID user)
 {
     if (_connectionStateMap.ContainsKey(user))
     {
         SteamUser.EndAuthSession(user);
         SteamNetworking.CloseP2PSessionWithUser(user);
         _connectionStateMap[user] = ConnectionState.Inactive;
         _reader.ClearUser(user);
         _writer.ClearUser(user);
     }
 }
 private void Close(CSteamID user)
 {
     if (_connectionStateMap.ContainsKey(user))
     {
         SteamNetworking.CloseP2PSessionWithUser(user);
         ClearAuthTicket();
         _connectionStateMap[user] = ConnectionState.Inactive;
         _lobby.Leave();
         _reader.ClearUser(user);
         _writer.ClearUser(user);
     }
 }
 private void Close(CSteamID user)
 {
     if (!this._connectionStateMap.ContainsKey(user))
     {
         return;
     }
     SteamUser.EndAuthSession(user);
     SteamNetworking.CloseP2PSessionWithUser(user);
     this._connectionStateMap.set_Item(user, NetSocialModule.ConnectionState.Inactive);
     this._reader.ClearUser(user);
     this._writer.ClearUser(user);
 }
예제 #16
0
        void RemoveConnection(CSteamID user)
        {
            int id;

            if (!connectionIds.TryGetValue(user, out id))
            {
                return;
            }
            SteamNetworking.CloseP2PSessionWithUser(user);
            connectionIds.Remove(user);
            connectionUsers.Remove(id);
        }
 private void Close(CSteamID user)
 {
     if (!this._connectionStateMap.ContainsKey(user))
     {
         return;
     }
     SteamNetworking.CloseP2PSessionWithUser(user);
     this.ClearAuthTicket();
     this._connectionStateMap[user] = NetSocialModule.ConnectionState.Inactive;
     this._lobby.Leave();
     this._reader.ClearUser(user);
     this._writer.ClearUser(user);
 }
 public void Stop()
 {
     //if(udpServer == null)
     //{
     //    return;
     //}
     //udpServer.Close();
     //udpServer.Dispose();
     foreach (NetworkPlayer player in NetServer.serverInstance.connections.ToArray())
     {
         SteamNetworking.CloseP2PSessionWithUser(player.steamID);
     }
 }
예제 #19
0
 private void CloseP2PSessions()
 {
     foreach (User user in connectedUsers.Values)
     {
         SteamNetworking.CloseP2PSessionWithUser(user.SteamId);
     }
     if (serverUser != null)
     {
         SteamNetworking.CloseP2PSessionWithUser(serverUser.SteamId);
     }
     connectedUsers.Clear();
     serverUser = null;
     // if (LogHelper.CurrentLogLevel <= LogLevel.Developer) LogHelper.LogInfo("SteamP2PTransport - CloseP2PSessions - has Closed P2P Sessions With all Users");
 }
예제 #20
0
 private void CloseP2PSessions()
 {
     foreach (User user in connectedUsers.Values)
     {
         SteamNetworking.CloseP2PSessionWithUser(user.SteamId);
     }
     if (serverUser != null)
     {
         SteamNetworking.CloseP2PSessionWithUser(serverUser.SteamId);
     }
     connectedUsers.Clear();
     serverUser = null;
     NetworkLog.LogInfoServer("SteamP2PTransport - CloseP2PSessions - has Closed P2P Sessions With all Users");
 }
		protected virtual void Dispose(bool disposing)
		{
			if (disposed)
				return;
			disposed = true;

			if (disposing)
			{
                //DISPOSE OF STEAM P2P SOCKET
                if (steamEndPoint.IsValid())
                {
                    SteamNetworking.CloseP2PSessionWithUser(steamEndPoint);
                }
			}
		}
예제 #22
0
        public bool ClientGetNextMessage(out TransportEvent transportEvent, out byte[] data)
        {
            transportEvent = TransportEvent.Disconnected;
            data           = null;

            //basic - Steam P2P doesnt have a real connection state
            if (steamClientServer == null || mode != Mode.CLIENT)
            {
                return(false);
            }

            if (steamClientServer.state == SteamClient.ConnectionState.DISCONNECTING)
            {
                if (LogFilter.Debug || debug)
                {
                    Debug.Log("We are currently trying to disconnect - so, disconnect");
                }
                transportEvent = TransportEvent.Disconnected;

                //make sure we dont communicate any more
                SteamNetworking.CloseP2PSessionWithUser(steamClientServer.steamID);

                //we are done being a client
                steamClientServer = null;
                mode = Mode.UNDEFINED;
                return(true);
            }

            if (steamClientServer.state == SteamClient.ConnectionState.CONNECTING && Time.time - clientConnectStarted > clientConnectTimeout)
            {
                Debug.LogWarning("Timeout while connecting..");

                ClientDisconnect();
                return(false);
            }

            //if we are not connecting or connected then we shouldnt get getting messages - exit here
            if (steamClientServer.state != SteamClient.ConnectionState.CONNECTED && steamClientServer.state != SteamClient.ConnectionState.CONNECTING)
            {
                return(false);
            }

            handleInternalMessages();

            int connectionId;

            return(ReceiveAndProcessEvents(out connectionId, out transportEvent, out data, (int)SteamChannels.SEND_TO_CLIENT));
        }
        private void OnLobbyEntered(LobbyEnter_t result, bool failure)
        {
            SteamNetworking.AllowP2PPacketRelay(true);
            SendAuthTicket(_lobby.Owner);
            int num = 0;
            P2PSessionState_t pConnectionState;

            while (SteamNetworking.GetP2PSessionState(_lobby.Owner, out pConnectionState) && pConnectionState.m_bConnectionActive != 1)
            {
                switch (pConnectionState.m_eP2PSessionError)
                {
                case 2:
                    ClearAuthTicket();
                    return;

                case 1:
                    ClearAuthTicket();
                    return;

                case 3:
                    ClearAuthTicket();
                    return;

                case 5:
                    ClearAuthTicket();
                    return;

                case 4:
                    if (++num > 5)
                    {
                        ClearAuthTicket();
                        return;
                    }
                    SteamNetworking.CloseP2PSessionWithUser(_lobby.Owner);
                    SendAuthTicket(_lobby.Owner);
                    break;
                }
            }
            _connectionStateMap[_lobby.Owner] = ConnectionState.Connected;
            SteamFriends.SetPlayedWith(_lobby.Owner);
            SteamFriends.SetRichPresence("status", "Playing online.");
            Main.clrInput();
            Netplay.ServerPassword = "";
            Main.GetInputText("");
            Main.autoPass = false;
            Main.netMode  = 1;
            Netplay.OnConnectedToSocialServer(new SocialSocket(new SteamAddress(_lobby.Owner)));
        }
예제 #24
0
        public void LeaveLobby()
        {
            if (lobbyID.m_SteamID != 0)
            {
                SteamMatchmaking.LeaveLobby(lobbyID);
            }
            foreach (ulong player in otherPlayers)
            {
                SteamNetworking.CloseP2PSessionWithUser((CSteamID)player);
            }
            connectedPlayers.Clear();
            otherPlayers.Clear();

            lobbyID  = new CSteamID(0);
            isInGame = false;
        }
예제 #25
0
    void OnLobbyChatUpdate(LobbyChatUpdate_t pCallback)
    {
        if (pCallback.m_rgfChatMemberStateChange == (uint)EChatMemberStateChange.k_EChatMemberStateChangeLeft && pCallback.m_ulSteamIDLobby == steamLobbyId.m_SteamID)
        {
            Debug.Log("A client has disconnected from the UNET server");

            // user left lobby
            var userId = new CSteamID(pCallback.m_ulSteamIDUserChanged);
            if (UNETServerController.IsHostingServer())
            {
                UNETServerController.RemoveConnection(userId);
            }

            SteamNetworking.CloseP2PSessionWithUser(userId);
        }
    }
예제 #26
0
 private void OnP2PSessionConnectFail(P2PSessionConnectFail_t callback)
 {
     if (P2PLogFilter.logError)
     {
         Debug.LogError(string.Format("[TransportLayerSteam] Connection error: {0} with steam user {1}", (EP2PSessionError)callback.m_eP2PSessionError, callback.m_steamIDRemote));
     }
     if (callback.m_eP2PSessionError != 0)
     {
         SteamNetworking.CloseP2PSessionWithUser(callback.m_steamIDRemote);
         int item;
         if (this.m_Connections.TryGetValue(callback.m_steamIDRemote, out item))
         {
             this.m_ConnectionsBrokenInternal.Push(item);
         }
     }
 }
예제 #27
0
        protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);

            if (remoteSteamId != CSteamID.Nil)
            {
                SteamNetworking.CloseP2PSessionWithUser(remoteSteamId);

                if (SteamNetManager.singleton.steamIdToConnection != null)
                {
                    SteamNetManager.singleton.steamIdToConnection.Remove(remoteSteamId);
                }

                remoteSteamId = CSteamID.Nil;
            }
        }
예제 #28
0
 private void Close(CSteamID user)
 {
     //IL_0006: 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_0022: Unknown result type (might be due to invalid IL or missing references)
     //IL_003a: Unknown result type (might be due to invalid IL or missing references)
     //IL_0046: Unknown result type (might be due to invalid IL or missing references)
     if (_connectionStateMap.ContainsKey(user))
     {
         SteamNetworking.CloseP2PSessionWithUser(user);
         ClearAuthTicket();
         _connectionStateMap[user] = ConnectionState.Inactive;
         _lobby.Leave();
         _reader.ClearUser(user);
         _writer.ClearUser(user);
     }
 }
예제 #29
0
 private void CloseP2PSessions()
 {
     foreach (User user in connectedUsers.Values)
     {
         SteamNetworking.CloseP2PSessionWithUser(user.SteamId);
     }
     if (serverUser != null)
     {
         SteamNetworking.CloseP2PSessionWithUser(serverUser.SteamId);
     }
     connectedUsers.Clear();
     serverUser = null;
     if (NetworkingManager.Singleton.LogLevel <= LogLevel.Developer)
     {
         UnityEngine.Debug.Log("SteamP2PTransport - CloseP2PSessions - has Closed P2P Sessions With all Users");
     }
 }
예제 #30
0
        void CloseAllConnections()
        {
            if (currentLobbyId == CSteamID.Nil)
            {
                return;
            }
            SteamMatchmaking.LeaveLobby(currentLobbyId);
            var playerCount = SteamMatchmaking.GetNumLobbyMembers(currentLobbyId);

            for (var i = 0; i < playerCount; i++)
            {
                var id = SteamMatchmaking.GetLobbyMemberByIndex(currentLobbyId, i);
                SteamNetworking.CloseP2PSessionWithUser(id);
            }
            Debug.Log($"[Steam] Left lobby {currentLobbyId}");
            currentLobbyId = CSteamID.Nil;
        }