added reason of disconnect at callback

This commit is contained in:
2023-05-08 00:16:43 +03:00
parent 91d8516ac9
commit 907bd2611e
9 changed files with 33 additions and 37 deletions
@@ -16,6 +16,7 @@
using ENet;
using Ragon.Protocol;
using Event = ENet.Event;
using EventType = ENet.EventType;
@@ -31,7 +32,7 @@ namespace Ragon.Client
public Action<byte[]> OnData { get; set; }
public Action OnConnected { get; set; }
public Action<DisconnectReason> OnDisconnected { get; set; }
public Action<RagonDisconnect> OnDisconnected { get; set; }
public ulong BytesSent { get; }
public ulong BytesReceived { get; }
public int Ping { get; }
@@ -98,10 +99,10 @@ namespace Ragon.Client
OnConnected?.Invoke();
break;
case EventType.Disconnect:
OnDisconnected?.Invoke(DisconnectReason.MANUAL);
OnDisconnected?.Invoke(RagonDisconnect.SERVER);
break;
case EventType.Timeout:
OnDisconnected?.Invoke(DisconnectReason.TIMEOUT);
OnDisconnected?.Invoke(RagonDisconnect.TIMEOUT);
break;
case EventType.Receive:
var data = new byte[_netEvent.Packet.Length];
@@ -16,6 +16,7 @@
using ENet;
using Ragon.Protocol;
using Event = ENet.Event;
using EventType = ENet.EventType;
@@ -31,7 +32,7 @@ namespace Ragon.Client
public Action<byte[]> OnData { get; set; }
public Action OnConnected { get; set; }
public Action<DisconnectReason> OnDisconnected { get; set; }
public Action<RagonDisconnect> OnDisconnected { get; set; }
public ulong BytesSent { get; }
public ulong BytesReceived { get; }
public int Ping { get; }
@@ -99,10 +100,10 @@ namespace Ragon.Client
OnConnected?.Invoke();
break;
case EventType.Disconnect:
OnDisconnected?.Invoke(DisconnectReason.MANUAL);
OnDisconnected?.Invoke(RagonDisconnect.SERVER);
break;
case EventType.Timeout:
OnDisconnected?.Invoke(DisconnectReason.TIMEOUT);
OnDisconnected?.Invoke(RagonDisconnect.TIMEOUT);
break;
case EventType.Receive:
var data = new byte[_netEvent.Packet.Length];