mirror of
https://github.com/PepperDash/PepperDashCore.git
synced 2026-02-16 21:24:43 +00:00
adds a null check to Receive()
This commit is contained in:
@@ -336,20 +336,24 @@ namespace PepperDash.Core
|
|||||||
/// <param name="numBytes"></param>
|
/// <param name="numBytes"></param>
|
||||||
void Receive(TCPClient client, int numBytes)
|
void Receive(TCPClient client, int numBytes)
|
||||||
{
|
{
|
||||||
if (numBytes > 0)
|
if (client != null)
|
||||||
{
|
{
|
||||||
var bytes = client.IncomingDataBuffer.Take(numBytes).ToArray();
|
if (numBytes > 0)
|
||||||
var bytesHandler = BytesReceived;
|
{
|
||||||
if (bytesHandler != null)
|
var bytes = client.IncomingDataBuffer.Take(numBytes).ToArray();
|
||||||
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
var bytesHandler = BytesReceived;
|
||||||
var textHandler = TextReceived;
|
if (bytesHandler != null)
|
||||||
if (textHandler != null)
|
bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
|
||||||
{
|
var textHandler = TextReceived;
|
||||||
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
if (textHandler != null)
|
||||||
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
{
|
||||||
}
|
var str = Encoding.GetEncoding(28591).GetString(bytes, 0, bytes.Length);
|
||||||
}
|
textHandler(this, new GenericCommMethodReceiveTextArgs(str));
|
||||||
Client.ReceiveDataAsync(Receive);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
client.ReceiveDataAsync(Receive);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user