protected override bool HandleIncomingMessage(uint messageType, ArraySegment<byte> messageChunk)
{
lock (DataLock)
{
m_responseRequired = true;
try
{
// process a response.
if (TcpMessageType.IsType(messageType, TcpMessageType.Message))
{
// Utils.Trace("Channel {0}: ProcessRequestMessage", ChannelId);
return ProcessRequestMessage(messageType, messageChunk);
}
// check for hello.
if (messageType == TcpMessageType.Hello)
{
// Utils.Trace("Channel {0}: ProcessHelloMessage", ChannelId);
return ProcessHelloMessage(messageType, messageChunk);
}
// process open secure channel repsonse.
if (TcpMessageType.IsType(messageType, TcpMessageType.Open))
{
// Utils.Trace("Channel {0}: ProcessOpenSecureChannelRequest", ChannelId);
return ProcessOpenSecureChannelRequest(messageType, messageChunk);
}
// process close secure channel response.
if (TcpMessageType.IsType(messageType, TcpMessageType.Close))
{
// Utils.Trace("Channel {0}: ProcessCloseSecureChannelRequest", ChannelId);
return ProcessCloseSecureChannelRequest(messageType, messageChunk);
}
// invalid message type - must close socket and reconnect.
ForceChannelFault(
StatusCodes.BadTcpMessageTypeInvalid,
"The server does not recognize the message type: {0:X8}.",
messageType);
return false;
}
finally
{
m_responseRequired = false;
}
}
}
#endregion