Fixed SocketInterface duplicate connections, callbacks

This commit is contained in:
Garry Newman 2020-02-24 11:33:52 +00:00
parent 44196682c8
commit 86a8f80584

View File

@ -32,10 +32,6 @@ namespace Steamworks
if ( SteamNetworkingSockets.Internal.IsValid ) if ( SteamNetworkingSockets.Internal.IsValid )
{ {
SteamNetworkingSockets.Internal.DestroyPollGroup( pollGroup ); SteamNetworkingSockets.Internal.DestroyPollGroup( pollGroup );
Console.WriteLine( "Closing Socket!" );
Console.WriteLine( Socket.ToString() );
Socket.Close(); Socket.Close();
} }
@ -49,15 +45,24 @@ namespace Steamworks
switch ( data.State ) switch ( data.State )
{ {
case ConnectionState.Connecting: case ConnectionState.Connecting:
OnConnecting( connection, data ); if ( !Connecting.Contains( connection ) )
{
OnConnecting( connection, data );
}
break; break;
case ConnectionState.Connected: case ConnectionState.Connected:
OnConnected( connection, data ); if ( !Connected.Contains( connection ) )
{
OnConnected( connection, data );
}
break; break;
case ConnectionState.ClosedByPeer: case ConnectionState.ClosedByPeer:
case ConnectionState.ProblemDetectedLocally: case ConnectionState.ProblemDetectedLocally:
case ConnectionState.None: case ConnectionState.None:
OnDisconnected( connection, data ); if ( Connecting.Contains( connection ) || Connected.Contains( connection ) )
{
OnDisconnected( connection, data );
}
break; break;
} }
} }
@ -69,8 +74,6 @@ namespace Steamworks
{ {
connection.Accept(); connection.Accept();
Connecting.Add( connection ); Connecting.Add( connection );
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup );
} }
/// <summary> /// <summary>
@ -80,6 +83,7 @@ namespace Steamworks
{ {
Connecting.Remove( connection ); Connecting.Remove( connection );
Connected.Add( connection ); Connected.Add( connection );
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup );
} }
/// <summary> /// <summary>
@ -87,6 +91,8 @@ namespace Steamworks
/// </summary> /// </summary>
public virtual void OnDisconnected( Connection connection, ConnectionInfo data ) public virtual void OnDisconnected( Connection connection, ConnectionInfo data )
{ {
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, 0 );
connection.Close(); connection.Close();
Connecting.Remove( connection ); Connecting.Remove( connection );