Beispiel #1
0
        /// <summary>
        /// User Data Relay received event handler.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">Event args.</param>
        private void UserDataRelayReceived(object sender, UserDataRelayReceivedEventArgs e)
        {
            UserDataRelayMessage message = e.UserDataRelayMessage;

            // Add the message to the list.
            ReceivedMessages.Add(string.Format("[{0}] {1}", message.SourceInterface.GetDescription(), Encoding.Default.GetString(message.Data)));
        }
Beispiel #2
0
 private void ReceivedNewMessage(string message)
 {
     App.Current.Dispatcher.Invoke(() =>
     {
         ReceivedMessages.Add(message);
     });
 }
Beispiel #3
0
        public AsyncTestDeDuplicatingActor(DeDuplicatingReceiverSettings settings, string persistenceId) : base(settings)
        {
            PersistenceId = persistenceId ?? Uri.EscapeUriString(Self.Path.ToStringWithoutAddress());

            CommandAsync <TestDeDuplicatingActor.ConfirmableMsg>(async c =>
            {
                _log.Info("async Received {0}", c);
                await Task.Delay(10);
                ReceivedMessages.Add(c.Msg);
                ConfirmAndReply(c);
                _log.Info("await Confirmed {0}", c);
            });

            Command <string>(str => str.Equals("crash"), str => { Crash(); });

            Command <string>(str => str.Equals("canConfirm"), str => { Sender.Tell(IsCurrentMessageConfirmable); });

            CommandAsync <string>(async str =>
            {
                _log.Info("async Received {0}", str);
                await Task.Delay(10);
                if (IsCurrentMessageConfirmable)
                {
                    ReceivedMessages.Add(str);
                    ConfirmAndReply(str);
                }
                _log.Info("await Processed {0}", str);
            });
        }
Beispiel #4
0
        MessagePayload ReceiveMessage()
        {
            lock (ReceiveLock)
            {
                lock (AliveLock)
                {
                    if (DeathException != null)
                    {
                        throw DeathException;
                    }
                }

                try
                {
                    var framer  = new MessageFramer(NetworkConfig.Magic);
                    var message = framer.NextMessage(Stream);
                    ReceivedMessages.Add(message);
                    return(message);
                }
                catch
                {
                    lock (AliveLock)
                    {
                        if (DeathException == null)
                        {
                            Alive          = false;
                            DeathException = new ConnectionDeadException("ReceiveMessage threw exception.");
                        }
                    }
                    throw DeathException;
                }
            }
        }
 private void TtsHelperMessageReceived(object sender,
                                       ReceivedMessageEventArgs e)
 {
     DispatcherHelper.UIDispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
     {
         ReceivedMessages.Add(e.Message);
     });
 }
Beispiel #6
0
        public void AddMessage(Guid id, int sequence, string originator, string text, string endpoint)
        {
            string       messageId  = id.ToString() + ":" + sequence;
            RumorMessage newMessage = new RumorMessage(messageId, originator, text, endpoint);

            newMessage.ReceivedStamp = DateTime.Now;
            ReceivedMessages.Add(newMessage);
        }
        public virtual Task <bool> Handle(T message)
        {
            ReceivedMessages.Add(message);

            OnHandle?.Invoke(message);

            return(Task.FromResult(ShouldSucceed));
        }
Beispiel #8
0
 public void AddMessage(RumorMessage message)
 {
     if (ReceivedMessages.Contains(message))
     {
         return;
     }
     message.ReceivedStamp = DateTime.Now;
     ReceivedMessages.Add(message);
 }
 private void NewMessageReceived(string message)
 {
     //write new message in collection to display in gui
     //switch thread to gui thread to avoid problems
     App.Current.Dispatcher.Invoke(() =>
     {
         ReceivedMessages.Add(message);
     });
 }
        private void ShowDEKafkaMessageInfo(object msg, string rawXml)
        {
            DEKafkaMessageViewModel vm = new DEKafkaMessageViewModel(rawXml, msg);

            CurrentDispatcher.Invoke(() =>
            {
                ReceivedMessages.Add(vm);
                ShowChangedRecords(msg);
            });
        }
 public virtual void Receive <TMessage>(Action <TMessage> handler) where TMessage : ITweakMessage
 {
     Messenger.Register <TMessage>(message =>
     {
         if (!DoReceive)
         {
             return;
         }
         ReceivedMessages.Add("Rx: " + message);
         handler(message);
     });
 }
Beispiel #12
0
 private void ExecuteSend()
 {
     client.Send(ChatName + ": " + Message);
     if (Message != "@quit")
     {
         ReceivedMessages.Add("ME: " + Message);
     }
     else
     {
         Disconnect();
         ReceivedMessages.Add("You disconnected");
     }
 }
Beispiel #13
0
 void Listener_Notify(object sender, NotifyEventArgs e)
 {
     if (e.Type == NotifyType.Received)
     {
         ReceivedMessages.Add(e.Message);
     }
     else if (e.Type == NotifyType.Sent)
     {
         SentMessages.Add(e.Message);
     }
     else
     {
         Messages.Add(e.Message);
     }
 }
Beispiel #14
0
        async Task OnMessageReceived(IMessage message)
        {
            if (Delay > TimeSpan.Zero)
            {
                await Task.Delay(Delay);
            }

            ReceivedMessages.Add(message);

            if (!(message is ISilverbackEvent) &&
                MustFailCount > FailCount || (FailCondition?.Invoke(message) ?? false))
            {
                FailCount++;
                throw new Exception("Test failure");
            }
        }
Beispiel #15
0
        /// <summary>
        ///     Handlers the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="eventArgs">The <see cref="MessageEventArgs{T}" /> instance containing the event data.</param>
        private void Handler(object sender, MessageEventArgs <T> eventArgs)
        {
            ReceivedMessages.Add(eventArgs);

            if (Filter != null)
            {
                if (Filter(eventArgs))
                {
                    MessageReceived.Set( );
                }
            }
            else
            {
                MessageReceived.Set( );
            }
        }
        public TestDeDuplicatingActor(DeDuplicatingReceiverSettings settings, string persistenceId) : base(settings)
        {
            PersistenceId = persistenceId ?? Uri.EscapeUriString(Self.Path.ToStringWithoutAddress());

            Command <ConfirmableMsg>(c =>
            {
                ReceivedMessages.Add(c.Msg);
                ConfirmAndReply(c);
            });

            Command <string>(str => str.Equals("crash"), str => { Crash(); });

            Command <string>(str => str.Equals("canConfirm"), str => { Sender.Tell(IsCurrentMessageConfirmable); });

            Command <string>(str =>
            {
                if (IsCurrentMessageConfirmable)
                {
                    ReceivedMessages.Add(str);
                    ConfirmAndReply(str);
                }
            });
        }
Beispiel #17
0
 /// Die Daten von den Clients werden verarbeitet
 public void HandleData(ServerClient client, Command command)
 {
     Console.WriteLine("Daten erhalten! ID: " + command.Identifier); /// Wird angezeigt, wenn ein Daten erhalten worden sind
     if (command.Identifier == "sendMessage")
     {
         List <Tuple <string, string> > messageDatas = new List <Tuple <string, string> >();
         if (ReceivedMessages.ContainsKey(client.Name))
         {
             messageDatas = ReceivedMessages[client.Name];
             ReceivedMessages.Remove(client.Name);
         }
         messageDatas.Add(new Tuple <string, string>(command.Arguments[0], command.Arguments[1]));
         ReceivedMessages.Add(client.Name, messageDatas);
         ServerClient receiver = GetClientByName(command.Arguments[0]);
         if (receiver != null)
         {
             receiver.Send(new Command("sendText", client.Name, command.Arguments[1]));
         }
     }
     else if (command.Identifier == "sendName")
     {
         client.Name = command.Arguments[0];
     }
 }
Beispiel #18
0
        /// <summary>
        /// Check request for IncomingMessages/DeliveryReports from Gateway,
        /// update Message collection or DeliveryReport collection
        /// </summary>
        /// <param name="doc">XmlDocument containing request from gateway</param>
        private XmlDocument CheckRequest(XmlDocument doc)
        {
            XmlDocument docResponse = new XmlDocument();
            XmlNode     nodMsgList  = doc.SelectSingleNode("MSGLST");

            if (nodMsgList != null)
            {
                // Loop through msg list
                foreach (XmlNode n in nodMsgList.ChildNodes)
                {
                    if (n.NodeType == XmlNodeType.Element && n.Name.Equals("MSG"))
                    {
                        string id = GetNodeValue(n, "ID");
                        int    i  = int.Parse(id);

                        // is this delivery report or incoming msg?
                        string state = GetNodeValue(n, "STATE");
                        if (state == null)
                        {
                            // Incoming Message
                            ReceivedMessages.Add(i, new Message());
                            ReceivedMessages[i].Text           = GetNodeValue(n, "TEXT");
                            ReceivedMessages[i].SenderNumber   = GetNodeValue(n, "SND");
                            ReceivedMessages[i].ReceiverNumber = GetNodeValue(n, "RCV");
                            ReceivedMessages[i].Network        = GetNodeValue(n, "NET");
                            ReceivedMessages[i]._Address       = GetNodeValue(n, "ADDRESS");

                            // Check if position data is included
                            XmlNode nodPosition = n.SelectSingleNode("POSITION");
                            if (nodPosition != null)
                            {
                                // Get position request results
                                ReceivedMessages[i]._Position = new PositionResult();
                                switch (GetNodeValue(nodPosition, "STATUS"))
                                {
                                case "OK":
                                    ReceivedMessages[i]._Position._Status = PositionRequestStatus.Ok;
                                    XmlNode nodPosData = nodPosition.SelectSingleNode("POS");
                                    if (nodPosData != null)
                                    {
                                        ReceivedMessages[i]._Position._PositionData                = new GSMPosition();
                                        ReceivedMessages[i]._Position._PositionData._Latitude      = GetNodeValue(nodPosData, "LATITUDE");
                                        ReceivedMessages[i]._Position._PositionData._Longitude     = GetNodeValue(nodPosData, "LONGITUDE");
                                        ReceivedMessages[i]._Position._PositionData._City          = GetNodeValue(nodPosData, "CITY");
                                        ReceivedMessages[i]._Position._PositionData._Council       = GetNodeValue(nodPosData, "COUNCIL");
                                        ReceivedMessages[i]._Position._PositionData._CouncilNumber = GetNodeValue(nodPosData, "COUNCILNUMBER", "").Equals("") ? -1 : int.Parse(GetNodeValue(nodPosData, "COUNCILNUMBER"));
                                        ReceivedMessages[i]._Position._PositionData._County        = GetNodeValue(nodPosData, "COUNTY");
                                        ReceivedMessages[i]._Position._PositionData._Place         = GetNodeValue(nodPosData, "PLACE");
                                        ReceivedMessages[i]._Position._PositionData._Radius        = GetNodeValue(nodPosData, "RADIUS", "").Equals("") ? -1 : int.Parse(GetNodeValue(nodPosData, "RADIUS"));
                                        ReceivedMessages[i]._Position._PositionData._SubPlace      = GetNodeValue(nodPosData, "SUBPLACE");
                                        ReceivedMessages[i]._Position._PositionData._ZipCode       = GetNodeValue(nodPosData, "ZIPCODE", "").Equals("") ? -1 : int.Parse(GetNodeValue(nodPosData, "ZIPCODE"));
                                    }
                                    break;

                                default:
                                    ReceivedMessages[i]._Position._Status       = PositionRequestStatus.Failed;
                                    ReceivedMessages[i]._Position._FailedReason = GetNodeValue(nodPosition, "INFO");
                                    break;
                                }
                            }
                        }
                        else
                        {
                            DeliveryReports.Add(i, new DeliveryReport());
                            DeliveryReports[i].State          = GetNodeValue(n, "STATE");
                            DeliveryReports[i].Reference      = GetNodeValue(n, "REF");
                            DeliveryReports[i].ReceiverNumber = GetNodeValue(n, "RCV");
                            string sDeliveryTime = GetNodeValue(n, "DELIVERYTIME");
                            if (sDeliveryTime != null && sDeliveryTime.Length > 0)
                            {
                                DeliveryReports[i].DeliveredDate = Convert.ToDateTime(sDeliveryTime);
                            }
                        }
                    }
                }

                // Build Response
                XmlElement elmMsgList = docResponse.CreateElement("MSGLST");
                foreach (int i in ReceivedMessages.Keys)
                {
                    XmlElement elmMsg = docResponse.CreateElement("MSG");
                    elmMsg.AppendChild(CreateElement(docResponse, "ID", i.ToString()));
                    elmMsg.AppendChild(CreateElement(docResponse, "STATUS", "OK"));
                    elmMsgList.AppendChild(elmMsg);
                }
                foreach (int i in DeliveryReports.Keys)
                {
                    XmlElement elmMsg = docResponse.CreateElement("MSG");
                    elmMsg.AppendChild(CreateElement(docResponse, "ID", i.ToString()));
                    elmMsg.AppendChild(CreateElement(docResponse, "STATUS", "OK"));
                    elmMsgList.AppendChild(elmMsg);
                }
                docResponse.AppendChild(elmMsgList);
            }
            return(docResponse);
        }
Beispiel #19
0
        private void client_OnMessageReceived(AbstractMessage message)
        {
            MessageInfo info = null;

            switch (message.MessageType)
            {
            case TemsInfoMessageType.Information:
                info = new MessageInfo(message as InformationMessage);
                break;

            case TemsInfoMessageType.Error:
                info = new MessageInfo(message as ErrorMessage);
                break;

            case TemsInfoMessageType.Heartbeat:
                HeartbeatMessage msgHeartbeat = message as HeartbeatMessage;
                if (lastHeartbeatSequenceNo.HasValue)
                {
                    uint expectedHeartbeatSequenceNo;
                    if (lastHeartbeatSequenceNo.HasValue && lastHeartbeatSequenceNo.Value < uint.MaxValue)
                    {
                        expectedHeartbeatSequenceNo = lastHeartbeatSequenceNo.Value + 1;
                    }
                    else
                    {
                        expectedHeartbeatSequenceNo = uint.MinValue;
                    }
                    if (expectedHeartbeatSequenceNo != msgHeartbeat.SequenceNo)
                    {
                        ctrlLog.AddLogMessage("Warning: Irregular heart beat sequence number (Last = {0:#,##0}, This = {1:#,##0})", lastHeartbeatSequenceNo, msgHeartbeat.SequenceNo);
                    }
                }
                lastHeartbeatSequenceNo = msgHeartbeat.SequenceNo;
                Dispatcher.BeginInvoke((Action)(() => {
                    txtHeartbeat.Text = string.Format("Heartbeat #: {0:#,##0}", msgHeartbeat.SequenceNo);
                }));
                break;

            case TemsInfoMessageType.Vehicle:
                info = new MessageInfo(message as VehicleMessage);
                break;

            case TemsInfoMessageType.ObjectStart:
                info = new MessageInfo(message as ObjectStartMessage);
                break;

            case TemsInfoMessageType.ObjectStop:
                info = new MessageInfo(message as ObjectStopMessage);
                break;

            case TemsInfoMessageType.ObjectLocation:
                info = new MessageInfo(message as ObjectLocationMessage);
                break;

            case TemsInfoMessageType.Status:
                info = new MessageInfo(message as StatusMessage);
                break;

            case TemsInfoMessageType.Value:
                info = new MessageInfo(message as ValueMessage);
                break;

            case TemsInfoMessageType.Data:
                info = new MessageInfo(message as DataMessage);
                break;

            case TemsInfoMessageType.Initialization:
            case TemsInfoMessageType.Configuration:
            case TemsInfoMessageType.SetSite:
            default:
                // Ignore because messages of this type
                // are never sent by the server
                break;
            }

            if (info != null)
            {
                Dispatcher.BeginInvoke((Action)(() => {
                    ReceivedMessages.Add(info);

                    while (ReceivedMessages.Count > MAX_DISPLAYED_MESSAGES)
                    {
                        ReceivedMessages[0].DeleteTemporaryDocumentFiles();
                        ReceivedMessages.RemoveAt(0);
                    }
                }));
            }
        }
Beispiel #20
0
 public void Handle(IMessage message)
 {
     ReceivedMessages.Add(message);
 }
Beispiel #21
0
 public Task <ReceiveResponse> Receive(Receivable receivable, CancellationToken cancellationToken = default)
 {
     ReceivedMessages.Add(receivable);
     return(Task.FromResult(new ReceiveResponse()));
 }
 public void Handle(int @event, PeerIdentity sender)
 {
     ReceivedMessages.Add(@event);
     MessageSenders.Add(sender);
 }