コード例 #1
0
        private static void TriggerNotifications(CampfireState campfireInfo)
        {
            IList <CampfireState.PendingNotify> pending = campfireInfo.PendingNotifications;

            foreach (CampfireState.PendingNotify pn in pending)
            {
                if (pn.TriggerTime < DateTime.Now)
                {
                    TriggerNotification(campfireInfo, pn.Reference);                                            // send notification
                    campfireInfo.RemovePendingNotification(pn.Reference.TargetUser.Id, pn.Reference.Room.Id);   // remove from pending list
                }
            }
        }
コード例 #2
0
        private static void ProcessTextMessage(CampfireState campfireInfo, Message msg, ICampfireAPI api)
        {
            // The person that posted this message... If they have a pending notification in the room... then cancel it... they've spoken
            campfireInfo.RemovePendingNotification(msg.UserId, msg.RoomId, msg.PostedAt, true);

            IList <CampfireState.UserInfo> allUsers = campfireInfo.Users;

            IList <CampfireState.UserReference> lazyNotificationUsers;
            IList <CampfireState.UserReference> immediateNotificationUsers;
            IList <CampfireState.UserReference> smokeSignalReferences;

            Utils.FindUserReferences(msg.Body, allUsers, out lazyNotificationUsers, out immediateNotificationUsers, out smokeSignalReferences);

            CampfireState.UserInfo source = allUsers.FirstOrDefault(u => u.Id == msg.UserId);
            CampfireState.RoomInfo room   = CampfireState.Instance.Rooms.FirstOrDefault(r => r.Id == msg.RoomId);

            // special smoke signal commands only make sense if a legitimate user issued them
            if (source != null)
            {
                foreach (CampfireState.UserReference ri in smokeSignalReferences)
                {
                    ri.SourceUser = source;
                    ri.Room       = room;
                    ProcessSmokeSignalCommands(source.Id, ri);
                }
            }

            foreach (CampfireState.UserReference ri in immediateNotificationUsers)
            {
                ri.SourceUser = source;
                ri.Room       = room;
                campfireInfo.AddPendingNotification(ri, msg.PostedAt.AddSeconds(0));
            }
            foreach (CampfireState.UserReference ri in lazyNotificationUsers)
            {
                ri.SourceUser = source;
                ri.Room       = room;

                int delay = ri.TargetUser.DelayInMinutes > 0 ? ri.TargetUser.DelayInMinutes : SmokeSignalConfig.Instance.DelayBeforeSmokeSignalInMinutes;
                campfireInfo.AddPendingNotification(ri, msg.PostedAt.AddSeconds(delay * 60));
            }
        }
コード例 #3
0
 private static void ProcessEnterMessage(CampfireState campfireInfo, Message msg, ICampfireAPI api)
 {
     // remove any pending notifications for this user in the room in which this Enter message appeared
     campfireInfo.RemovePendingNotification(msg.UserId, msg.RoomId, msg.PostedAt, true);
 }
コード例 #4
0
        private static void ProcessTextMessage(CampfireState campfireInfo, Message msg, ICampfireAPI api)
        {
            // The person that posted this message... If they have a pending notification in the room... then cancel it... they've spoken
            campfireInfo.RemovePendingNotification(msg.UserId, msg.RoomId, msg.PostedAt, true);

            IList<CampfireState.UserInfo> allUsers = campfireInfo.Users;

            IList<CampfireState.UserReference> lazyNotificationUsers;
            IList<CampfireState.UserReference> immediateNotificationUsers;
            IList<CampfireState.UserReference> smokeSignalReferences;
            Utils.FindUserReferences(msg.Body, allUsers, out lazyNotificationUsers, out immediateNotificationUsers, out smokeSignalReferences);

            CampfireState.UserInfo source = allUsers.FirstOrDefault(u => u.Id == msg.UserId);
            CampfireState.RoomInfo room = CampfireState.Instance.Rooms.FirstOrDefault(r => r.Id == msg.RoomId);

            // special smoke signal commands only make sense if a legitimate user issued them
            if (source != null)
            {
                foreach (CampfireState.UserReference ri in smokeSignalReferences)
                {
                    ri.SourceUser = source;
                    ri.Room = room;
                    ProcessSmokeSignalCommands(source.Id, ri);
                }
            }

            foreach (CampfireState.UserReference ri in immediateNotificationUsers)
            {
                ri.SourceUser = source;
                ri.Room = room;
                campfireInfo.AddPendingNotification(ri, msg.PostedAt.AddSeconds(0));
            }
            foreach (CampfireState.UserReference ri in lazyNotificationUsers)
            {
                ri.SourceUser = source;
                ri.Room = room;

                int delay = ri.TargetUser.DelayInMinutes > 0 ? ri.TargetUser.DelayInMinutes : SmokeSignalConfig.Instance.DelayBeforeSmokeSignalInMinutes;
                campfireInfo.AddPendingNotification(ri, msg.PostedAt.AddSeconds(delay * 60));
            }
        }
コード例 #5
0
        private static void TriggerNotifications(CampfireState campfireInfo)
        {
            IList<CampfireState.PendingNotify> pending = campfireInfo.PendingNotifications;

            foreach (CampfireState.PendingNotify pn in pending)
            {
                if (pn.TriggerTime < DateTime.Now)
                {
                    TriggerNotification(campfireInfo, pn.Reference);                                            // send notification
                    campfireInfo.RemovePendingNotification(pn.Reference.TargetUser.Id, pn.Reference.Room.Id);   // remove from pending list
                }
            }
        }
コード例 #6
0
 private static void ProcessEnterMessage(CampfireState campfireInfo, Message msg, ICampfireAPI api)
 {
     // remove any pending notifications for this user in the room in which this Enter message appeared
     campfireInfo.RemovePendingNotification(msg.UserId, msg.RoomId, msg.PostedAt, true);
 }