/// <summary>
        /// Adds a message in the room
        /// </summary>
        /// <param name="strMsg"></param>
        /// <param name="senderID"></param>
        /// <param name="toUserID"></param>
        /// <returns>All the messages sent from the other user from the last time the user sent a message</returns>
        public string SendMessage(string strMsg,string senderID,string toUserID)
        {
            ChatUser user=this.GetUser(senderID);

            Message msg=new Message(user.UserName ,strMsg,MsgType.Msg);

            user.LastSeen=DateTime.Now;

            this.ExpireUsers(100);

            this.AddMsg(msg);

            int lastMsgID;

            ArrayList previousMsgs= this.GetMessagesSince( user.LastMessageReceived,out lastMsgID);

            if (lastMsgID!=-1)

                user.LastMessageReceived=lastMsgID;

            string res=this.GenerateMessagesString(previousMsgs);

            return res;
        }
        /// <summary>
        /// Activates the user and adds a join message to the room
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="userName"></param>
        /// <returns>All the messages sent in the room</returns>
        public string JoinRoom(string userID,string userName)
        {
            //activate user

            ChatUser user=this.GetUser(userID);

            user.IsActive=true;

            user.UserName=userName;

            user.LastSeen=DateTime.Now;

            //Add join message

            Message msg=new Message(user.UserName ,"",MsgType.Join);

            this.AddMsg(msg);

            //Get all the messages to the user

            int lastMsgID;

            ArrayList previousMessages=this.GetMessagesSince(-1,out lastMsgID);

            user.LastMessageReceived=lastMsgID;

            //return the messages to the user

            string str=GenerateMessagesString(previousMessages);

            return str;
        }
        //
        /// <summary>
        /// Marks the user as inactive
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public string LeaveRoom(string userID)
        {
            //deactivate user

            ChatUser user=this.GetUser(userID);

            user.IsActive=false;

            user.LastSeen=DateTime.Now;

            //Add leaving message

            Message msg = new Message(user.UserName ,"",MsgType.Left);

            this.AddMsg(msg);

            //Get all the messages to the user

            int lastMsgID;

            ArrayList previousMsgs= this.GetMessagesSince( user.LastMessageReceived,out lastMsgID);

            user.LastMessageReceived=lastMsgID;

            //return the messages to the user

            string str=GenerateMessagesString(previousMsgs);

            if (IsEmpty())

                ChatEngine.DeleteRoom(this.RoomID);

            return "";
        }
        /// <summary>
        /// Adds a message to the room
        /// <param name="msg"></param>
        /// <returns> the id of the new message</returns>
        public int AddMsg(Message msg)
        {
            int count;

            lock(messages)

            {

                count = messages.Count;

                messages.Add(msg);

            }

            return count;
        }