ISocketManager.OnDisconnected is in charge of calling Connection.Close so custom parameters can be used

This commit is contained in:
André Straubmeier 2020-08-17 13:49:22 +02:00
parent 5fdffff5c4
commit 498c1b9a32
2 changed files with 13 additions and 8 deletions

View File

@ -16,7 +16,7 @@ public interface ISocketManager
void OnConnected( Connection connection, ConnectionInfo info );
/// <summary>
/// Called when the connection leaves
/// Called when the connection leaves. Must call Close on the connection
/// </summary>
void OnDisconnected( Connection connection, ConnectionInfo info );

View File

@ -50,6 +50,7 @@ public virtual void OnConnectionChanged( Connection connection, ConnectionInfo i
if ( !Connecting.Contains( connection ) )
{
Connecting.Add( connection );
OnConnecting( connection, info );
}
break;
@ -67,6 +68,9 @@ public virtual void OnConnectionChanged( Connection connection, ConnectionInfo i
case ConnectionState.None:
if ( Connecting.Contains( connection ) || Connected.Contains( connection ) )
{
Connecting.Remove( connection );
Connected.Remove( connection );
OnDisconnected( connection, info );
}
break;
@ -81,7 +85,6 @@ public virtual void OnConnecting( Connection connection, ConnectionInfo info )
if ( Interface != null )
{
Interface.OnConnecting( connection, info );
return;
}
else
{
@ -106,12 +109,14 @@ public virtual void OnDisconnected( Connection connection, ConnectionInfo info )
{
SteamNetworkingSockets.Internal.SetConnectionPollGroup( connection, 0 );
if ( Interface != null )
{
Interface.OnDisconnected( connection, info );
}
else
{
connection.Close();
Connecting.Remove( connection );
Connected.Remove( connection );
Interface?.OnDisconnected( connection, info );
}
}
public void Receive( int bufferSize = 32 )