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

ProcessErrorMessage() protected method

Processes an Error message received over the socket.
protected ProcessErrorMessage ( uint messageType, ArraySegment messageChunk ) : bool
messageType uint
messageChunk ArraySegment
return bool
        protected bool ProcessErrorMessage(uint messageType, ArraySegment<byte> messageChunk)
        {
            Utils.Trace("Channel {0}: ProcessErrorMessage()", ChannelId);

            // read request buffer sizes.            
            MemoryStream istrm = new MemoryStream(messageChunk.Array, messageChunk.Offset, messageChunk.Count, false);
            BinaryDecoder decoder = new BinaryDecoder(istrm, Quotas.MessageContext);

            istrm.Seek(TcpMessageLimits.MessageTypeAndSize, SeekOrigin.Current);

            try
            {                
                ServiceResult error = ReadErrorMessageBody(decoder);
                
                // check if a handshake is in progress
                if (m_handshakeOperation != null)
                {
                    m_handshakeOperation.Fault(error);
                    return false;
                }

                // handle the fatal error.
                ForceReconnect(error);
                return false;
            }
            finally
            {
                decoder.Close();
            }
        }