Beispiel #1
0
 private void postMessageResponseHandler(MessagePoster.MessageStatus status, Conversation conversation, string message)
 {
     try
     {
         this.BeginInvoke((MethodInvoker) delegate
         {
             //Console.Write(status +  " " + message + "\n");
             if (status == MessagePoster.MessageStatus.Success || status == MessagePoster.MessageStatus.ConversationNotFound || status == MessagePoster.MessageStatus.MessageEmpty)
             {
                 messagesToSend.Dequeue();
             }
             if (messagesToSend.Count > 0)
             {
                 sendEnqueuedMessage();
             }
             else
             {
                 poster = null;
             }
         });
     }
     catch (InvalidOperationException e)
     {
         //form closed
     }
 }
Beispiel #2
0
 private void MessagePosterDelegate(MessagePoster.MessageStatus status, Conversation conversation, string message)
 {
     //Console.Write(status +  " " + message + "\n");
     if (status == MessagePoster.MessageStatus.Success || status == MessagePoster.MessageStatus.ConversationNotFound || status == MessagePoster.MessageStatus.MessageEmpty)
     {
         //Success
         poster = null;
         Result?.Invoke(EnumConverter.Convert <MessageSendStatus>(status), messageBeingSent);
         if (Sending)
         {
             sendEnqueuedMessage();
         }
     }
     else if (RetryOnFail)            // Jei nepavyko
     {
         Thread.Sleep(RetryInterval); // Palaukiam ir bandom išnaujo
         poster = new MessagePoster(PrivateKey, MessagePosterDelegate);
         poster.post(messageBeingSent.Conversation, messageBeingSent.Text);
         return;
     }
 }