void downloader_PageDownloaded(object sender, PageDownloadedEventArgs e) { var downloader = (ISiteDownloader)sender; var sessionId = downloader.SessionId; var connectionId = ChatHub.GetConnectionId(sessionId); if (!string.IsNullOrEmpty(connectionId)) { //GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.Client(connectionId).broadcastMessage("test", "downloader_PageDownloaded"); GlobalHost.ConnectionManager.GetHubContext <ChatHub>().Clients.Client(connectionId).onPageDownloaded(new { CurrentPage = e.DownloadedPage, DownloadedPages = downloader.DownloadedPages.Count, Remains = downloader.DownloadQueue.Count }); } }
void downloader_DownloadCompleted(object sender, DownloadCompletedEventArgs e) { var downloader = (ISiteDownloader)sender; var sessionId = ((ISiteDownloader)sender).SessionId; var connectionId = ChatHub.GetConnectionId(sessionId); if (!string.IsNullOrEmpty(connectionId)) { //GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.Client(connectionId).broadcastMessage("test", "downloader_DownloadCompleted"); GlobalHost.ConnectionManager.GetHubContext <ChatHub>().Clients.Client(connectionId).onDownloadCompleted(e.DownloadedPages); } SiteDownloaderFactory.RemoveSiteDownloader(sessionId); }