diff --git a/Facepunch.Steamworks/Networking/SocketInterface.cs b/Facepunch.Steamworks/Networking/SocketInterface.cs index 73917ac..91b416e 100644 --- a/Facepunch.Steamworks/Networking/SocketInterface.cs +++ b/Facepunch.Steamworks/Networking/SocketInterface.cs @@ -32,10 +32,6 @@ public bool Close() if ( SteamNetworkingSockets.Internal.IsValid ) { SteamNetworkingSockets.Internal.DestroyPollGroup( pollGroup ); - - Console.WriteLine( "Closing Socket!" ); - Console.WriteLine( Socket.ToString() ); - Socket.Close(); } @@ -49,15 +45,24 @@ public virtual void OnConnectionChanged( Connection connection, ConnectionInfo d switch ( data.State ) { case ConnectionState.Connecting: - OnConnecting( connection, data ); + if ( !Connecting.Contains( connection ) ) + { + OnConnecting( connection, data ); + } break; case ConnectionState.Connected: - OnConnected( connection, data ); + if ( !Connected.Contains( connection ) ) + { + OnConnected( connection, data ); + } break; case ConnectionState.ClosedByPeer: case ConnectionState.ProblemDetectedLocally: case ConnectionState.None: - OnDisconnected( connection, data ); + if ( Connecting.Contains( connection ) || Connected.Contains( connection ) ) + { + OnDisconnected( connection, data ); + } break; } } @@ -69,8 +74,6 @@ public virtual void OnConnecting( Connection connection, ConnectionInfo data ) { connection.Accept(); Connecting.Add( connection ); - - SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup ); } /// @@ -80,6 +83,7 @@ public virtual void OnConnected( Connection connection, ConnectionInfo data ) { Connecting.Remove( connection ); Connected.Add( connection ); + SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup ); } /// @@ -87,6 +91,8 @@ public virtual void OnConnected( Connection connection, ConnectionInfo data ) /// public virtual void OnDisconnected( Connection connection, ConnectionInfo data ) { + SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, 0 ); + connection.Close(); Connecting.Remove( connection );