コード例 #1
0
        public async Task RemoveConnectionFromChat(ChatRoom chat, IConnection con, RemoveReason reason)
        {
            using (var alock = await Data.Synchronizer.SetStateAsync(ModuleState.Writing))
            {
                if (!chat.Connections.Contains(con))
                {
                    throw new ArgumentException("Connection " + con.Id + " is no member of chat " + chat.Id + ".");
                }

                Data.RemoveConnectionFromChat(chat, con);

                if (reason != RemoveReason.ChatClosed)
                {
                    await Broadcast(Messages.ConnectionLeftChat(chat, con));
                }

                if (reason != RemoveReason.Request)
                {
                    await Messenger.SendMessage(con, Messages.RemovedFromChat(chat, reason.ToString()));
                }

                if (chat.CloseIfEmpty && chat.IsEmpty)
                {
                    await CloseChatRoom(chat);
                }
            }
        }
コード例 #2
0
 private void ItemRemovedCallback(object key, object value, RemoveReason removedReason, object state)
 {
     //if the item was removed from the cache, log the key and reason to the event log
     try
     {
         _logger.LogInformation("ItemRemovedCallback:key:" + key + ", reason:" + removedReason.ToString());
     }
     catch (Exception exc)
     {
         //Swallow exception
         _logger.LogError(exc, "ItemRemovedCallbackError");
     }
 }
コード例 #3
0
 protected override void HandleRemove(ExchangePrincipal key, StoreSession value, RemoveReason reason)
 {
     Factory.Current.LocalTaskTracer.TraceInformation <Guid, string, string>(this.GetHashCode(), 0L, "Correlation Id:{0}. Removing MailboxSession for mailbox:{1} from the cache, removal reason is {2}", this.queryCorrelationId, key.ToString(), reason.ToString());
     base.HandleRemove(key, value, reason);
     if (this.OnRemovedFromCache != null)
     {
         this.OnRemovedFromCache(key, reason);
     }
 }