internal StackPacket[] DecodePacketCallback(
object endPoint,
byte[] receivedBytes,
out int consumedLength,
out int expectedLength)
{
StackPacket pdu = null;
expectedLength = 0;
// Get bytes for only one packet
byte[] packetData = GetPacket(receivedBytes);
if (null == packetData)
{
// Received bytes does not contain enough data
consumedLength = 0;
return null;
}
consumedLength = packetData.Length;
// Decode PDU
try
{
pdu = DecodePdu(packetData);
if (pdu.GetType() == typeof(Server_X_224_Connection_Confirm_Pdu))
{
// Negotiation-based security-enhanced Connection
client.UpdateTransport();
}
}
catch (FormatException e)
{
pdu = new ErrorPdu(e);
}
// Update client context and client
clientContext.UpdateContext(pdu);
client.CheckDecryptionCount();
return new StackPacket[] { pdu };
}