Ejemplo n.º 1
0
 public ConsumerWorker(IMessageQueue queue, IMessageStrategy messageStrategy, IRepository <Message> repository, ILogger <ConsumerWorker> logger)
 {
     this.queue           = queue;
     this.messageStrategy = messageStrategy;
     this.repository      = repository;
     this.logger          = logger;
 }
Ejemplo n.º 2
0
        public IMessageStrategy RetrieveMessageStrategy(IMessage message)
        {
            IMessageStrategy strategy = null;

            this.messageStrategies.TryGetValue(message.GetType(), out strategy);
            return(strategy);
        }
Ejemplo n.º 3
0
        public List <string> DecodeMessageToList(byte[] message)
        {
            List <string> decodedMessage = new List <string>();

            decodedMessage.Clear();
            IMessageStrategy str = null;

            switch (message[0])
            {
            case (byte)Constants.MessageType.MESSTYPE_LOCATION:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_LOCATION);
                decodedMessage = str.Decode(message).ToList();
                break;

            case (byte)Constants.MessageType.MESSTYPE_ALERT:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_ALERT);
                decodedMessage = str.Decode(message).ToList();
                break;

            case (byte)Constants.MessageType.MESSTYPE_EVENT:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_EVENT);
                decodedMessage = str.Decode(message).ToList();
                break;

            case (byte)Constants.MessageType.MESSTYPE_ELS95:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_ELS95);
                decodedMessage = str.Decode(message).ToList();
                break;

            case (byte)Constants.MessageType.MESSTYPE_MODE:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_MODE);
                decodedMessage = str.Decode(message).ToList();
                break;

            //case (byte)Constants.MessageType.MESSTYPE_FILEDESC:
            //    str = GetMessageStrategy(Constants.MessageType.MESSTYPE_FILEDESC);
            //    decodedMessage = str.Decode(message).ToList();
            //    break;

            case (byte)Constants.MessageType.MESSTYPE_EHE2:
                str            = GetMessageStrategy(Constants.MessageType.MESSTYPE_EHE2);
                decodedMessage = str.Decode(message).ToList();
                break;

            default:
                decodedMessage.Add("Message type Error");
                break;
            }

            return(decodedMessage);
        }
Ejemplo n.º 4
0
        public void ExecuteStrategy(IMessage message, IPaxosRoleState currentState)
        {
            IMessageStrategy messageStrategy = this.RetrieveMessageStrategy(message);

            if (messageStrategy == null)
            {
                return;
            }

            MessageStrategyExecuteArg <IMessage> arg = new MessageStrategyExecuteArg <IMessage>
            {
                RoleState = currentState,
                Message   = message
            };

            messageStrategy.Execute(arg);
        }
Ejemplo n.º 5
0
 public Message(IMessageStrategy strategy)
 {
     this.Strategy = strategy;
 }
Ejemplo n.º 6
0
 public void AddStrategy(Type t, IMessageStrategy strategy)
 {
     this.messageStrategies.Add(t, strategy);
 }
Ejemplo n.º 7
0
 public CompositeMessageStrategy(
     IMessageStrategy s1, IMessageStrategy s2)
 {
     _s1 = s1;
     _s2 = s2;
 }
Ejemplo n.º 8
0
 public MessageContext(IMessageStrategy strategy)
 {
     this.messageStrategy = strategy;
 }