Opc.Ua.Bindings.TcpMessageType.IsType C# (CSharp) Method

IsType() public static method

Returns true if the message type is equal to the expected type.
public static IsType ( uint actualType, uint expectedType ) : bool
actualType uint
expectedType uint
return bool
        public static bool IsType(uint actualType, uint expectedType)
        {
            return ((actualType & MessageTypeMask) == expectedType);
        }

Usage Example

コード例 #1
0
        /// <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);
                }
            }
        }