Opc.Ua.Bindings.TcpClientChannel.HandleIncomingMessage C# (CSharp) Method

HandleIncomingMessage() protected method

Processes an incoming message.
protected HandleIncomingMessage ( uint messageType, ArraySegment messageChunk ) : bool
messageType uint
messageChunk ArraySegment
return bool
        protected override bool HandleIncomingMessage(uint messageType, ArraySegment<byte> messageChunk)
        {        
            lock (DataLock)
            { 
                // process a response.
                if (TcpMessageType.IsType(messageType, TcpMessageType.Message))
                {
                    //Utils.Trace("Channel {0}: ProcessResponseMessage", ChannelId);
                    return ProcessResponseMessage(messageType, messageChunk);
                }

                // check for acknowledge.
                else if (messageType == TcpMessageType.Acknowledge)
                {
                    //Utils.Trace("Channel {0}: ProcessAcknowledgeMessage", ChannelId);
                    return ProcessAcknowledgeMessage(messageChunk);
                }

                // check for error.
                else if (messageType == TcpMessageType.Error)
                {
                    //Utils.Trace("Channel {0}: ProcessErrorMessage", ChannelId);
                    return ProcessErrorMessage(messageType, messageChunk);
                }

                // process open secure channel repsonse.
                else if (TcpMessageType.IsType(messageType, TcpMessageType.Open))
                {
                    //Utils.Trace("Channel {0}: ProcessOpenSecureChannelResponse", ChannelId);
                    return ProcessOpenSecureChannelResponse(messageType, messageChunk);
                }

                // process a response to a close request.
                else if (TcpMessageType.IsType(messageType, TcpMessageType.Close))
                {
                    //Utils.Trace("Channel {0}: ProcessResponseMessage (close)", ChannelId);
                    return ProcessResponseMessage(messageType, messageChunk);
                }

                // invalid message type - must close socket and reconnect.
                ForceReconnect(ServiceResult.Create(StatusCodes.BadTcpMessageTypeInvalid, "The client does not recognize the message type: {0:X8}.", messageType));
                return false;
            }
        }