Пример #1
0
        private static void ProcessMessages_FetchNewMessages(CampfireState campfireInfo, ICampfireAPI api)
        {
            IList <CampfireState.RoomInfo> rooms = campfireInfo.Rooms;

            foreach (CampfireState.RoomInfo room in rooms)
            {
                List <Message> msgs;
                try
                {
                    msgs = api.RecentMessages(room.Id, room.LastMessageId, Message.MType.TextMessage | Message.MType.EnterMessage);
                }
                catch (System.Net.WebException ex)
                {
                    // oops. Let's break out and then try again later
                    Utils.TraceException(TraceLevel.Warning, ex, "Exception calling API.RecentMessages");
                    break;
                }

                int lastMsgId = 0;
                foreach (Message msg in msgs)
                {
                    lastMsgId = msg.Id;
                    QueueMessage(campfireInfo, msg);
                }

                if (lastMsgId != 0)
                {
                    // remember that we've now processed through this message Id. So next time we're only fetch newer messages
                    campfireInfo.UpdateLastMessageId(room.Id, lastMsgId);
                }
            }
        }
Пример #2
0
        private static void ProcessMessages_FetchNewMessages(CampfireState campfireInfo, ICampfireAPI api)
        {
            IList<CampfireState.RoomInfo> rooms = campfireInfo.Rooms;

            foreach (CampfireState.RoomInfo room in rooms)
            {
                List<Message> msgs;
                try
                {
                    msgs = api.RecentMessages(room.Id, room.LastMessageId, Message.MType.TextMessage | Message.MType.EnterMessage);
                }
                catch (System.Net.WebException ex)
                {
                    // oops. Let's break out and then try again later
                    Utils.TraceException(TraceLevel.Warning, ex, "Exception calling API.RecentMessages");
                    break;
                }

                int lastMsgId = 0;
                foreach (Message msg in msgs)
                {
                    lastMsgId = msg.Id;
                    QueueMessage(campfireInfo, msg);
                }

                if (lastMsgId != 0)
                {
                    // remember that we've now processed through this message Id. So next time we're only fetch newer messages
                    campfireInfo.UpdateLastMessageId(room.Id, lastMsgId);
                }
            }
        }