Example #1
0
        public bool RetreiveMessages(out IList <Message> addMsgs)
        {
            bool needToReset = false;

            if (!conn.HasTimeFilter()) // Means the filter changed and need to reload all the messages
            {
                this.messageList = new List <Message>();
                needToReset      = true;
            }

            addMsgs = conn.RetreiveMessages();
            if (addMsgs.Count > 0)
            {
                needToReset = (AddByKeepUniqueGuid(this.messageList, addMsgs) | needToReset);

                if (messageList.Count > msgLimit)
                {
                    for (int i = 0; i < messageList.Count - msgLimit; i++)
                    {
                        this.messageList.RemoveAt(0);
                    }

                    needToReset = true;
                }
            }

            if (needToReset)
            {
                addMsgs = this.messageList;
            }

            conn.SetTimeFilter(DateTime.UtcNow); // For receiving only new messages

            return(needToReset);
        }