Esempio n. 1
0
        public void SendMessage(MessagePayload message)
        {
            lock (SendLock)
            {
                lock (AliveLock)
                {
                    if (DeathException != null)
                    {
                        throw DeathException;
                    }
                }

                try
                {
                    Byte[] data = message.ToBytes();
                    Stream.Write(data, 0, data.Length);
                    SentMessages.Add(message);
                }
                catch
                {
                    lock (AliveLock)
                    {
                        if (DeathException == null)
                        {
                            Alive          = false;
                            DeathException = new ConnectionDeadException("SendMessage threw exception.");
                        }
                    }
                    throw DeathException;
                }
            }
        }
 public void EndMessage()
 {
     if (!SentMessages.Contains(Step))
     {
         SentMessages.Add(Step);
         EndOfInstructionText?.Invoke(CycleID);
     }
 }
Esempio n. 3
0
        public void BookingDeletedMessage(string receiverId)
        {
            var content     = $"Your booking at {Name} was deleted.";
            var messageData = new MessageData("Booking Deleted", content);
            var metadata    = new MessageMetadata(false, false);

            SentMessages.Add(new Message(Id, receiverId, messageData, MessageType.BookingDeleted, metadata));
        }
 void EndMessage()
 {
     Ended           = true;
     message.endTime = StepCount;
     SentMessages.Add(message);
     AllTime          += message.delayTime;
     Form1.AverageTime = AllTime / SentMessages.Count;
 }
Esempio n. 5
0
 public bool SendMessage(string channel, string message)
 {
     SentToChannel = channel;
     SentMessages.Add(message);
     // TODO: Implement some kind of event trigger when a message is sent so
     //       that unit tests can use longer timeouts but still complete as soon
     //       as a message is sent..
     return(true);
 }
Esempio n. 6
0
 public void ShowPotiResultPicture(Dictionary <EngineData.AI, int> analogResults = null, Dictionary <EngineData.DI, int> digiResults = null, string resourceName = null)
 {
     if (!SentMessages.Contains(Step))
     {
         ShowPotiPicture?.Invoke(CycleId, analogResults, digiResults, resourceName);
         SentMessages.Add(Step);
         HMI.PanelStatus(EngineData.Screens.ImageMachineResults);
     }
 }
Esempio n. 7
0
        public virtual UserMessage SendMessage(User to, string subject, string body, bool highPriority)
        {
            ParamIs.NotNull(() => to);

            var msg = new UserMessage(this, to, subject, body, highPriority);

            SentMessages.Add(msg);
            to.ReceivedMessages.Add(msg);

            return(msg);
        }
Esempio n. 8
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);
     }
 }
Esempio n. 9
0
        internal Task PostMessageAsync(OutgoingMessage message, CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();
            SentMessages.Add(message);

            if (SimulateFailure)
            {
                throw new JsonApiException(new Error(HttpStatusCode.ServiceUnavailable)
                {
                    Title = "Message delivery failed."
                });
            }

            return(Task.CompletedTask);
        }
Esempio n. 10
0
        public virtual Tuple <UserMessage, UserMessage> SendMessage(User to, string subject, string body, bool highPriority)
        {
            ParamIs.NotNull(() => to);

            var received = UserMessage.CreateReceived(this, to, subject, body, highPriority);

            to.ReceivedMessages.Add(received);
            to.Messages.Add(received);

            var sent = UserMessage.CreateSent(this, to, subject, body, highPriority);

            SentMessages.Add(sent);
            Messages.Add(sent);

            return(Tuple.Create(received, sent));
        }
 public ZenBotMessageQueue(ILoopBreaker loopBreaker, ChatBotConnection connection, int queueSize = 4)
 {
     QueueSize   = queueSize;
     LoopBreaker = loopBreaker;
     Connection  = connection;
     for (int i = 0; i < queueSize; i++)
     {
         SentMessages.Add(new ZenBotMessage()
         {
             Message = ""
         });
         ReceivedAnswers.Add(new ZenBotMessage()
         {
             Message = ""
         });
     }
 }
Esempio n. 12
0
        public bool StartScanner(string name)
        {
            if (!SentMessages.Contains(Step))
            {
                if (CounterTimeout < 100)
                {
                    TriggerScanner?.Invoke(name, true);
                    SentMessages.Add(Step);
                    CounterTimeout++;
                }
                else
                {
                    CounterTimeout = 0;
                    return(false);
                }

                return(true);
            }
            CounterTimeout = 0;
            return(false);
        }
        public void SendMessage(ZenBotMessage message)
        {
            if (SentMessages.Contains(message))
            {
                message.Message = LoopBreaker.GetRandomMessage();
            }
            SentMessages.Add(message);
            var answer = Connection.SendMessage(message.Message).Result;

            ReceivedAnswers.Add(new ZenBotMessage()
            {
                Message = answer
            });
            if (ReceivedAnswers.Count > QueueSize)
            {
                ReceivedAnswers.RemoveAt(0);
            }

            if (SentMessages.Count > QueueSize)
            {
                SentMessages.RemoveAt(0);
            }
        }
Esempio n. 14
0
 public void ClearInstructions()
 {
     SentMessages.Add(Step);
     ClearInstructionText?.Invoke(CycleID);
 }
Esempio n. 15
0
 public override void Send(string queue, Message message)
 {
     SentMessages.Add(message);
 }
 public new void Send(Message message)
 {
     MessageWasSent = true;
     SentMessages.Add(message);
     OnMessagePublished?.Invoke(true, message.Id);
 }
Esempio n. 17
0
 public void SendMessage(SmsMessage sendMessage)
 {
     SentMessages.Add(sendMessage);
     System.Diagnostics.Trace.WriteLine($"SendMessage: {sendMessage.phone} - {sendMessage.message}");
 }
 public Task SendAsync(SenderMessage message, CancellationToken cancellationToken)
 {
     SentMessages.Add(message);
     return(Task.CompletedTask);
 }
Esempio n. 19
0
 public Result Send(RealtimeTransportData data)
 {
     _sendAction(data);
     SentMessages.Add(data);
     return(Result.Ok());
 }
Esempio n. 20
0
 public void Send(RealtimeTransportData data)
 {
     SendAction(data);
     SentMessages.Add(data);
 }