Skip to content

Commit 764bd68

Browse files
committed
Add received client/server packet events.
1 parent 72c6159 commit 764bd68

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

TibiaAPI/Network/Connection.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public class Connection : Communication, IDisposable
6060
private bool _isSendingToServer = false;
6161
private bool _isStarted;
6262

63+
public delegate bool ReceivedMessageEventHandler(byte[] data);
64+
65+
public event ReceivedMessageEventHandler OnReceivedClientMessage;
66+
public event ReceivedMessageEventHandler OnReceivedServerMessage;
67+
6368
/// <summary>
6469
/// Initializes a new instance of the <see cref="Connection"/> class that acts as a proxy
6570
/// between the Tibia client and the game server.
@@ -704,6 +709,7 @@ private void BeginReceiveClientCallback(IAsyncResult ar)
704709
else
705710
{
706711
_clientInMessage.PrepareToParse(_xteaKey);
712+
OnReceivedClientMessage?.Invoke(_clientInMessage.GetData());
707713

708714
if (_isPacketParsingEnabled)
709715
{
@@ -777,6 +783,7 @@ private void BeginReceiveServerCallback(IAsyncResult ar)
777783
if (protocol == 1)
778784
{
779785
_serverInMessage.PrepareToParse(_xteaKey, _zStream);
786+
OnReceivedServerMessage?.Invoke(_serverInMessage.GetData());
780787

781788
if (_isPacketParsingEnabled)
782789
{

0 commit comments

Comments
 (0)