Exemplo n.º 1
0
        private void timerCallback(object state)
        {
            var channel = channelInformationManager.CurrentChannel.Value;
            var time    = channelInformationManager.CurrentTime.Value;

            if (channel != null && time.HasValue)
            {
                SynchronizationContext.Post((_) =>
                {
                    for (int i = RegisteredServices.Count - 1; i >= 0; i--)
                    {
                        ChatCollectService.IChatCollectService service = RegisteredServices[i];
                        try
                        {
                            NewChatProduced?.Invoke(service.GetChats(channel, time.Value + TimeAdjustment.Value).Select(chat =>
                            {
                                chat.SetSourceService(service.ServiceEntry);
                                return(chat);
                            }));
                        }
                        catch (ChatCollectService.ChatCollectException e)
                        {
                            registeredServices.Remove(service);
                            ErrorOccurredInChatCollecting?.Invoke(service, e.Message);
                            service.Dispose();
                        }
                    }
                }, null);
            }
        }
Exemplo n.º 2
0
 public async void PostChat(ChatCollectService.IChatCollectService service, ChatCollectService.BasicChatPostObject postObject)
 {
     if (!service.CanPost)
     {
         ErrorOccurredInChatPosting(service, postObject, "このコメント元はコメント投稿をサポートしていません");
         return;
     }
     try
     {
         await service.PostChat(postObject);
     }
     catch (ChatCollectService.ChatPostException e)
     {
         ErrorOccurredInChatPosting(service, postObject, e.Message);
     }
 }
Exemplo n.º 3
0
 public void RemoveService(ChatCollectService.IChatCollectService service)
 {
     registeredServices.Remove(service);
     service.Dispose();
 }