/// <summary>
/// Processes an incoming message.
/// </summary>
/// <returns>True if the implementor takes ownership of the buffer.</returns>
protected override bool HandleIncomingMessage(uint messageType, ArraySegment <byte> messageChunk)
{
lock (DataLock)
{
SetResponseRequired(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(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
{
SetResponseRequired(false);
}
}
}