private RoomWatcher <DefaultWebSocket> NewRoomWatcherFor(int roomNumber)
        {
            var newRoomWatcher =
                new RoomWatcher <DefaultWebSocket>(this.auth, $"https://chat.stackoverflow.com/rooms/{roomNumber}");
            var messageHandler = new ChatEventHandler();
            var scheduler      = new SharpExchange.Chat.Actions.ActionScheduler(this.auth, Host, roomNumber);
            var router         = new CommandRouter(this, roomNumber,
                                                   scheduler);

            messageHandler.OnEvent += router.RouteCommand;
            newRoomWatcher.EventRouter.AddProcessor(messageHandler);

            scheduler.CreateMessageAsync("Hello friends!");

            return(newRoomWatcher);
        }
예제 #2
0
        public static Task <bool> DeleteMessageAsync(this ActionScheduler actionScheduler, int messageId)
        {
            var action = new MessageDeleter(messageId);

            return(actionScheduler.ScheduleActionAsync <bool>(action));
        }
예제 #3
0
        public static Task <bool> DeleteMessageAsync(this ActionScheduler actionScheduler, Chat.Message message)
        {
            message.ThrowIfNull(nameof(message));

            return(DeleteMessageAsync(actionScheduler, message.Id));
        }
예제 #4
0
        public static Task <bool> KickMuteUserAsync(this ActionScheduler actionScheduler, int userId)
        {
            var action = new UserKickMuter(userId);

            return(actionScheduler.ScheduleActionAsync <bool>(action));
        }
예제 #5
0
        public static Task <bool> KickMuteUser(this ActionScheduler actionScheduler, Chat.User user)
        {
            user.ThrowIfNull(nameof(user));

            return(KickMuteUserAsync(actionScheduler, user.Id));
        }
예제 #6
0
        public static Task ChangeUserAccessLevelAsync(this ActionScheduler actionScheduler, int userId, UserAccessLevel newLevel)
        {
            var action = new UserAccessLevelEditor(userId, newLevel);

            return(actionScheduler.ScheduleActionAsync <bool>(action));
        }
예제 #7
0
        public static Task ChangeUserAccessLevelAsync(this ActionScheduler actionScheduler, Chat.User user, UserAccessLevel newLevel)
        {
            user.ThrowIfNull(nameof(user));

            return(ChangeUserAccessLevelAsync(actionScheduler, user.Id, newLevel));
        }
예제 #8
0
        public static Task <bool> ToggleStarAsync(this ActionScheduler actionScheduler, int messageId)
        {
            var action = new MessageStarToggler(messageId);

            return(actionScheduler.ScheduleActionAsync <bool>(action));
        }