예제 #1
0
		/// <summary>
		/// Adds an item to the cache directly
		/// </summary>
		public void Update(ChatItemHolder chatItem)
		{
			if (!Online)
				return;

			lock (itemCache)
			{
				try
				{
					itemCache.Add(chatItem);
				}
				catch (Exception ex)
				{
					Status(ex.ToString(), true);
				}
			}
			cleanOutIfNeeded();
		}
예제 #2
0
		/// <summary>
		/// Add an item to the room
		/// </summary>
		/// <param name="xml"></param>
		public void AddItem(string item, Guid itemGuid)
		{
			Status("ChatRoom.AddItem", false);

			//record the time of this post
			lastItemPosted = DateTime.Now;

			long ticks = DateTime.Now.Ticks;

			ChatItemHolder thisItem = new ChatItemHolder(item, itemGuid, itemGuid, this.RoomGuid, DateTime.Now);

			//if we already have a post recorded at this time (unlikely), add one to make it unique - I think we can change this so it indexes by guid, rather than this ticks bullshit...
			lock (itemCache)
			{
				//add the item to the cache
				itemCache.Add(thisItem);
				
				//cleanOutIfNeeded();
				while (itemCache.Count > cacheCapacity)
					itemCache.RemoveAt(0);

			}

			//update users about the change
			lock (users)
			{
				foreach (User registeredUser in users.Values)
				{
					if (registeredUser.Online)
						registeredUser.Update(thisItem);
				}
			}
		}