Пример #1
0
        /// <summary>
        /// Returns session with given id, or null if it doesn't exist.
        /// </summary>
        /// <param name="sessionId"></param>
        /// <returns></returns>
        public ChatSession Get(long sessionId)
        {
            ChatSession result = null;

            lock (_sessions)
                _sessions.TryGetValue(sessionId, out result);
            return(result);
        }
Пример #2
0
		/// <summary>
		/// Removes session from manager.
		/// </summary>
		/// <param name="session"></param>
		public void Remove(ChatSession session)
		{
			lock (_sessions)
				_sessions.Remove(session.Id);
		}
Пример #3
0
		/// <summary>
		/// Adds session to manager.
		/// </summary>
		/// <param name="session"></param>
		public void Add(ChatSession session)
		{
			lock (_sessions)
				_sessions[session.Id] = session;
		}
Пример #4
0
 /// <summary>
 /// Removes session from manager.
 /// </summary>
 /// <param name="session"></param>
 public void Remove(ChatSession session)
 {
     lock (_sessions)
         _sessions.Remove(session.Id);
 }
Пример #5
0
 /// <summary>
 /// Adds session to manager.
 /// </summary>
 /// <param name="session"></param>
 public void Add(ChatSession session)
 {
     lock (_sessions)
         _sessions[session.Id] = session;
 }
Пример #6
0
		/// <summary>
		/// Notifies session user about user closing chat window.
		/// </summary>
		/// <param name="session"></param>
		/// <param name="user"></param>
		public static void ChatLeave(ChatSession session, User user)
		{
			var packet = new Packet(Op.Msgr.ChatLeave, 0);

			packet.PutLong(session.Id);
			packet.PutInt(user.Id);

			session.Broadcast(packet);
		}
Пример #7
0
		/// <summary>
		/// Sends initial chat session information to user.
		/// </summary>
		/// <param name="user"></param>
		/// <param name="session"></param>
		public static void ChatJoin(User user, ChatSession session)
		{
			var users = session.GetUsers();

			var packet = new Packet(Op.Msgr.ChatJoin, 0);

			packet.PutLong(session.Id);
			packet.PutInt(users.Length);
			foreach (var sessionUser in users)
			{
				packet.PutInt(sessionUser.Id);
				packet.PutString(sessionUser.FullName);
			}

			user.Client.Send(packet);
		}
Пример #8
0
		/// <summary>
		/// Broadcasts chat message in session.
		/// </summary>
		/// <param name="session"></param>
		/// <param name="contactId"></param>
		/// <param name="message"></param>
		public static void ChatR(ChatSession session, int contactId, string message)
		{
			var packet = new Packet(Op.Msgr.ChatR, 0);

			packet.PutLong(session.Id);
			packet.PutInt(contactId);
			packet.PutString(message);

			session.Broadcast(packet);
		}
Пример #9
0
		/// <summary>
		/// Notifies users about someone joining the chat.
		/// </summary>
		/// <param name="session"></param>
		/// <param name="user"></param>
		public static void ChatInviteR(ChatSession session, User user)
		{
			var packet = new Packet(Op.Msgr.ChatInviteR, 0);

			packet.PutLong(session.Id);
			packet.PutInt(user.Id);
			packet.PutString(user.FullName);
			packet.PutString(user.Nickname);

			session.Broadcast(packet);
		}