private void OnDeviceMessage(RawMessage message)
        {
            DeviceMessage deviceMessage = new DeviceMessage();

            deviceMessage.content = message.ToString();
            deviceMessageListener.OnDeviceMessage(deviceMessage);
        }
Exemplo n.º 2
0
        public async Task SendMessageAsync(RawMessage message)
        {
            var line = message.ToString();
            await _writer.WriteLineAsync(line);

            await _writer.FlushAsync();
        }
Exemplo n.º 3
0
        public static void ShowConfirm(string MessageId, MsgBuilder MessageBuilder, WebControl cntrlName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            MessageBuilder.MsgRepository[MessageId] = theMsg.ToString();
            string theDynamicMsg = MessageBuilder.BuildMessage(MessageId);

            ShowConfirm(theDynamicMsg, theMsg.Type.ToString(), theMsg.Buttons.ToString(), cntrlName);
        }
Exemplo n.º 4
0
        public static string GetMessage(string MessageId, MsgBuilder MessageBuilder, Control frmName = null)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            MessageBuilder.MsgRepository[MessageId] = theMsg.ToString();
            string theDynamicMsg = MessageBuilder.BuildMessage(MessageId);

            return(theDynamicMsg.ToString());
        }
Exemplo n.º 5
0
        public static void ShowforUpdatePanel(string MessageId, MsgBuilder MessageBuilder, Control frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            MessageBuilder.MsgRepository[MessageId] = theMsg.ToString();
            string theDynamicMsg = MessageBuilder.BuildMessage(MessageId);

            ShowforUpdatePanel(theDynamicMsg, theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName);
        }
Exemplo n.º 6
0
        public static void ShowfromPage(string MessageId, MsgBuilder MessageBuilder, Page frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            MessageBuilder.MsgRepository[MessageId] = theMsg.ToString();
            string theDynamicMsg = MessageBuilder.BuildMessage(MessageId);

            Showfrompage(theDynamicMsg, theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName);
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MessageId">For retrieving message from xml file corresponding to MessageId</param>
        /// <param name="MessageBuilder">Send user defined message</param>
        /// <param name="frmName">The form control on which message will be shown</param>
        public static DialogResult ShowWindowConfirm(string MessageId, MsgBuilder MessageBuilder, System.Windows.Forms.Control frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            MessageBuilder.MsgRepository[MessageId] = theMsg.ToString();
            string theDynamicMsg = MessageBuilder.BuildMessage(MessageId);

            //ShowConfirm(theDynamicMsg, theMsg.Type.ToString(), theMsg.Buttons.ToString(), cntrlName);
            return(ShowWindow(theDynamicMsg, theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName));
        }
Exemplo n.º 8
0
        public static new void ToString()
        {
            RawMessage message = new RawMessage();

            message.Prefix = new RawMessagePrefix("[email protected]");
            message.Command = "PRIVMSG";
            message.Arguments = new string[] { "rec", "message goes here" };

            Assert.AreEqual(":[email protected] PRIVMSG rec :message goes here", message.ToString());
        }
        private void OnCommandV3(RawMessage message)
        {
            CommandV3 commandV3 = JsonUtil.ConvertJsonStringToObject <CommandV3>(message.ToString());

            if (commandV3 == null)
            {
                Log.Error("invalid commandV3");
                return;
            }

            if (commandV3Listener != null)
            {
                commandV3Listener.OnCommandV3(commandV3);
            }
        }
Exemplo n.º 10
0
        public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
        {
            log.ErrorFormat("Message {0} moved to error queue", message.ToString());

            // If retry count is not reset to 0, replaying this message will immediatly fail it again
            // Store the original retry count in a header for diagnostic purposes
            if (message.RetryCount != 0)
            {
                message.Headers.Add("OriginalRetryCount", message.RetryCount.ToString());
                message.RetryCount = 0;
            }

            // Useful for diagnostics
            message.Headers.Add("ExceptionMessage", this.ExceptionMessage);

            transport.SendToError(message);
        }
Exemplo n.º 11
0
        public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
        {
            log.WarnFormat("Message {0} moved to error queue", message.ToString());

            // If retry count is not reset to 0, replaying this message will immediatly fail it again
            // Store the original retry count in a header for diagnostic purposes
            if (message.RetryCount != 0)
            {
                message.Headers.Add("OriginalRetryCount", message.RetryCount.ToString());
                message.RetryCount = 0;
            }

            // Useful for diagnostics
            message.Headers.Add("ExceptionMessage", this.ExceptionMessage);

            transport.SendToError(message);
        }
        private void OnPropertiesGet(RawMessage message)
        {
            string requestId = IotUtil.GetRequestId(message.Topic);

            PropsGet propsGet = JsonUtil.ConvertJsonStringToObject <PropsGet>(message.ToString());

            if (propsGet == null)
            {
                return;
            }

            if (propertyListener != null && (propsGet.deviceId == null || propsGet.deviceId == this.deviceId))
            {
                propertyListener.OnPropertiesGet(requestId, propsGet.serviceId);

                return;
            }

            device.OnPropertiesGet(requestId, propsGet);
        }
        public void OnCommand(RawMessage message)
        {
            string requestId = IotUtil.GetRequestId(message.Topic);

            Command command = JsonUtil.ConvertJsonStringToObject <Command>(message.ToString());

            if (command == null)
            {
                Log.Error("invalid command");

                return;
            }

            if (commandListener != null && (command.deviceId == null || command.deviceId == deviceId))
            {
                commandListener.OnCommand(requestId, command.serviceId, command.commandName, command.paras);

                return;
            }

            device.OnCommand(requestId, command);
        }
Exemplo n.º 14
0
        public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
        {
            if (WillRetry(message.RetryCount))
            {
                message.RetryCount++;
                log.InfoFormat("Message requested to be retried {0} - Retry Count {1}", message.ToString(), message.RetryCount);

                // Exponential backoff with a 90% - 110% jitter added to avoid synchronized backoffs on failures.
                var delayTime = TimeSpan.FromMilliseconds((Math.Pow(4, message.RetryCount) * 100) * (1.0 + (new Random().NextDouble() - 0.5) / 5));
                message.RetryCount = message.RetryCount;

                // Convert to a delay result and process
                var delayResult = new DelayResult(DateTime.UtcNow.Add(delayTime));
                delayResult.ProcessResult(message, transport, log);
            }
            else
            {
                // Out of retries, convert to a fail result
                var failResult = new FailResult(this.Message);
                failResult.ProcessResult(message, transport, log);
            }
        }
        private void OnEvent(RawMessage message)
        {
            DeviceEvents deviceEvents = JsonUtil.ConvertJsonStringToObject <DeviceEvents>(message.ToString());

            if (deviceEvents == null)
            {
                Log.Error("invalid events");
                return;
            }

            device.OnEvent(deviceEvents);
        }
Exemplo n.º 16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MessageId">For retrieving message from xml file corresponding to MessageId </param>
        /// <param name="frmName">The form control on which message will be shown</param>
        public static void ShowWindow(string MessageId, System.Windows.Forms.Control frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            ShowWindow(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName);
        }
Exemplo n.º 17
0
        public static string GetMessage(string MessageId, Control frmName = null)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            return(theMsg.ToString());
        }
Exemplo n.º 18
0
        public static void Show(string MessageId, Page frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            Show(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName);
        }
Exemplo n.º 19
0
 public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
 {
     log.DebugFormat("Message {0} ignored for reason {1}", message.ToString(), this.reason);
 }
Exemplo n.º 20
0
 public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
 {
     log.DebugFormat("Delaying message {0} until {1}", message.ToString(), this.DelayUntil.ToString());
     message.DelayUntil = this.DelayUntil;
     transport.SendToDelay(message);
 }
Exemplo n.º 21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="MessageId">For retrieving message from xml file corresponding to MessageId </param>
        /// <param name="frmName">The form control on which message will be shown</param>
        public static DialogResult ShowWindowConfirm(string MessageId, Control frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            return(ShowWindow(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName));
        }
Exemplo n.º 22
0
        public static void ShowforUpdatePanel(string MessageId, Control frmName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            ShowforUpdatePanel(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), frmName);
        }
Exemplo n.º 23
0
        public static void ShowConfirm(string MessageId, WebControl cntrlName)
        {
            RawMessage theMsg = MsgRepository.GetMessage(MessageId);

            ShowConfirm(theMsg.ToString(), theMsg.Type.ToString(), theMsg.Buttons.ToString(), cntrlName);
        }
Exemplo n.º 24
0
 public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
 {
     log.DebugFormat("Message {0} ignored for reason {1}", message.ToString(), this.reason);
 }
Exemplo n.º 25
0
        public async Task SendMessageAsync(RawMessage message)
        {
            var line = message.ToString();

            this._socket.Send(line);
        }
Exemplo n.º 26
0
        public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
        {
            if (message.RetryCount < ConfigurationContext.Current.MessageRetryLimit)
            {
                message.RetryCount++;
                log.InfoFormat("Message requested to be retried {0} - Retry Count {1}", message.ToString(), message.RetryCount);

                // Exponential backoff with a 90% - 110% jitter added to avoid synchronized backoffs on failures.
                var delayTime = TimeSpan.FromMilliseconds((Math.Pow(4, message.RetryCount) * 100) * (1.0 + (new Random().NextDouble() - 0.5) / 5));
                message.RetryCount = message.RetryCount;

                // Convert to a delay result and process
                var delayResult = new DelayResult(DateTime.UtcNow.Add(delayTime));
                delayResult.ProcessResult(message, transport, log);
            }
            else
            {
                // Out of retries, convert to a fail result
                var failResult = new FailResult(this.Message);
                failResult.ProcessResult(message, transport, log);
            }
        }
Exemplo n.º 27
0
 public void Write(RawMessage message)
 {
     this.source.Write(message.ToString() + messageDivider);
     this.source.Flush();
 }
Exemplo n.º 28
0
        public void TestSerialization(string expected, RawMessage message)
        {
            var actual = message.ToString();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 29
0
 public void ProcessResult(RawMessage message, ITransport transport, ILogger log)
 {
     log.DebugFormat("Delaying message {0} until {1}", message.ToString(), this.DelayUntil.ToString());
     message.DelayUntil = this.DelayUntil;
     transport.SendToDelay(message);
 }