mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2024-12-26 14:45:51 +03:00
Fixed SocketInterface duplicate connections, callbacks
This commit is contained in:
parent
44196682c8
commit
86a8f80584
@ -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 );
|
||||
|
Loading…
Reference in New Issue
Block a user