Beispiel #1
0
        public void AddMessage(string contentType, string message)
        {
            ExTraceGlobals.InstantMessagingTracer.TraceDebug((long)this.GetHashCode(), "InstantMessageQueue.AddMessage");
            Interlocked.CompareExchange <List <Tuple <string, string> > >(ref this.messageList, new List <Tuple <string, string> >(), null);
            bool flag = false;

            lock (this.lockObject)
            {
                if (this.messageList.Count < 20)
                {
                    if (string.IsNullOrWhiteSpace(contentType))
                    {
                        contentType = "text/plain;charset=utf-8";
                    }
                    this.messageList.Add(new Tuple <string, string>(contentType, message));
                }
                else
                {
                    flag = true;
                }
            }
            if (flag)
            {
                ExTraceGlobals.InstantMessagingTracer.TraceError((long)this.GetHashCode(), "InstantMessageQueue.AddMessage. Message queued count: {0}", new object[]
                {
                    this.messageList.Count
                });
                InstantMessagePayloadUtilities.GenerateMessageNotDeliveredPayload(this.notifier, "InstantMessageQueue.AddMessage", this.Conversation.Cid, UserActivityType.FailedDelivery);
            }
        }
Beispiel #2
0
        private void SendMessageCallback(IAsyncResult result)
        {
            IIMModality iimmodality = null;

            try
            {
                ExTraceGlobals.InstantMessagingTracer.TraceDebug((long)this.GetHashCode(), "InstantMessageQueue.SendMessageCallback");
                iimmodality = (result.AsyncState as IIMModality);
                if (iimmodality == null)
                {
                    ExTraceGlobals.InstantMessagingTracer.TraceError((long)this.GetHashCode(), "InstantMessageQueue.SendMessageCallback. Instant Messaging Modality is null.");
                }
                else
                {
                    iimmodality.EndSendMessage(result);
                }
            }
            catch (InstantMessagingException ex)
            {
                InstantMessagePayloadUtilities.GenerateMessageNotDeliveredPayload(this.notifier, "InstantMessageQueue.SendMessageCallback", (iimmodality == null || iimmodality.Conversation == null) ? 0 : iimmodality.Conversation.Cid, ex);
                InstantMessagingError code = ex.Code;
                if (code <= 18102)
                {
                    if (code == 0)
                    {
                        goto IL_DB;
                    }
                    if (code == 18102)
                    {
                        InstantMessagingErrorSubCode subCode = ex.SubCode;
                        if (subCode != 9)
                        {
                            InstantMessageUtilities.SendWatsonReport("InstantMessageQueue.SendMessageCallback", this.userContext, ex);
                            goto IL_DB;
                        }
                        goto IL_DB;
                    }
                }
                else if (code == 18201 || code == 18204)
                {
                    goto IL_DB;
                }
                InstantMessageUtilities.SendWatsonReport("InstantMessageQueue.SendMessageCallback", this.userContext, ex);
                IL_DB :;
            }
            catch (Exception exception)
            {
                InstantMessageUtilities.SendWatsonReport("InstantMessageQueue.SendMessageCallback", this.userContext, exception);
            }
        }