Ejemplo n.º 1
0
        public async Task Initialize(ITwitchChatService twitchChatService)
        {
            this.RebuildCommandTriggers();

            await ChannelSession.Services.FileService.CreateDirectory(ChatEventLogDirectoryName);

            this.currentChatEventLogFilePath = Path.Combine(ChatEventLogDirectoryName, string.Format(ChatEventLogFileNameFormat, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)));

            List <ChatMessageViewModel> messagesToAdd = new List <ChatMessageViewModel>();

            if (twitchChatService != null)
            {
                this.TwitchChatService = twitchChatService;

                this.TwitchChatService.OnMessageOccurred    += TwitchChatService_OnMessageOccurred;
                this.TwitchChatService.OnUsersJoinOccurred  += TwitchChatService_OnUsersJoinOccurred;
                this.TwitchChatService.OnUsersLeaveOccurred += TwitchChatService_OnUsersLeaveOccurred;

                await this.TwitchChatService.Initialize();
            }

            await DispatcherHelper.InvokeDispatcher(() =>
            {
                foreach (ChatMessageViewModel message in messagesToAdd)
                {
                    this.messagesLookup[message.ID] = message;
                    if (ChannelSession.Settings.LatestChatAtTop)
                    {
                        this.Messages.Insert(0, message);
                    }
                    else
                    {
                        this.Messages.Add(message);
                    }
                }
                return(Task.FromResult(0));
            });

            AsyncRunner.RunBackgroundTask(this.cancellationTokenSource.Token, 60000, this.ProcessHoursCurrency);
        }
Ejemplo n.º 2
0
        public async Task Initialize(ITwitchChatService twitchChatService)
        {
            this.RebuildCommandTriggers();

            await ChannelSession.Services.FileService.CreateDirectory(ChatEventLogDirectoryName);

            this.currentChatEventLogFilePath = Path.Combine(ChatEventLogDirectoryName, string.Format(ChatEventLogFileNameFormat, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss", CultureInfo.InvariantCulture)));

            if (twitchChatService != null)
            {
                this.TwitchChatService = twitchChatService;

                this.TwitchChatService.OnMessageOccurred    += TwitchChatService_OnMessageOccurred;
                this.TwitchChatService.OnUsersJoinOccurred  += TwitchChatService_OnUsersJoinOccurred;
                this.TwitchChatService.OnUsersLeaveOccurred += TwitchChatService_OnUsersLeaveOccurred;

                await this.TwitchChatService.Initialize();
            }

#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            AsyncRunner.RunAsyncBackground(this.ProcessHoursCurrency, this.cancellationTokenSource.Token, 60000);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
        }