예제 #1
0
        /// <summary>
        /// This message resolves any local handlers that can process the message.
        /// </summary>
        /// <param name="payload">The payload to resolve.</param>
        /// <param name="messageHandlers">A list containing the message handlers that can process the message.</param>
        /// <returns>Returns true of there are message handlers that can process the payload.</returns>
        public bool ResolveMessageHandlers(TransmissionPayload payload, out List <ICommand> messageHandlers)
        {
            messageHandlers = null;
            //Check if the message key exisits in the dictionary
            string messageKey = ServiceMessageHeader.ToKey(payload.Message);

            //Get the message handler
            if (!mMessageMap.TryGetValue(messageKey, out messageHandlers))
            {
                return(ResolveMessageHandlers(payload.Message, out messageHandlers));
            }

            return(messageHandlers.Count > 0);
        }
예제 #2
0
        protected virtual bool SupportedResolve(ServiceMessageHeader header, out H command)
        {
            foreach (var item in mSupported)
            {
                if (item.Key.Message.Header.IsPartialKey)
                {
                    string partialkey = item.Key.Message.Header.ToPartialKey();

                    if (header.ToKey().StartsWith(partialkey))
                    {
                        command = item.Value;
                        return(true);
                    }
                }
                else if (item.Key.Message.Header.Equals(header))
                {
                    command = item.Value;
                    return(true);
                }
            }

            command = null;
            return(false);
        }
예제 #3
0
 /// <summary>
 /// This method converts the message response metadata in to a header.
 /// </summary>
 /// <returns></returns>
 public virtual string ToResponseKey()
 {
     return(ServiceMessageHeader.ToKey(ResponseChannelId, ResponseMessageType, ResponseActionType));
 }
예제 #4
0
 /// <summary>
 /// This method converts the message metadata in to a header.
 /// </summary>
 /// <returns></returns>
 public virtual string ToKey()
 {
     return(ServiceMessageHeader.ToKey(ChannelId, MessageType, ActionType));
 }