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 @@ 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 );
}
/// <summary>
@ -80,6 +83,7 @@ public virtual void OnConnected( Connection connection, ConnectionInfo data )
{
Connecting.Remove( connection );
Connected.Add( connection );
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, pollGroup );
}
/// <summary>
@ -87,6 +91,8 @@ public virtual void OnConnected( Connection connection, ConnectionInfo data )
/// </summary>
public virtual void OnDisconnected( Connection connection, ConnectionInfo data )
{
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, 0 );
connection.Close();
Connecting.Remove( connection );