Rename CrowdfundHubStream to AppHubSteamer

This commit is contained in:
nicolas.dorier 2019-02-19 13:18:30 +09:00
parent 50c8525012
commit cc444811db
11 changed files with 17 additions and 27 deletions

View File

@ -5,10 +5,8 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using BTCPayServer.Controllers;
using BTCPayServer.Crowdfund;
using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.Hubs;
using BTCPayServer.Models;
using BTCPayServer.Models.AppViewModels;
using BTCPayServer.Models.StoreViewModels;

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using BTCPayServer.Crowdfund;
using BTCPayServer.Data;
using BTCPayServer.Filters;
using BTCPayServer.Models;
@ -42,7 +41,6 @@ namespace BTCPayServer.Controllers
private AppService _AppService;
private InvoiceController _InvoiceController;
private readonly CrowdfundHubStreamer _CrowdfundHubStreamer;
private readonly UserManager<ApplicationUser> _UserManager;
[HttpGet]

View File

@ -38,8 +38,6 @@ using BTCPayServer.Logging;
using BTCPayServer.HostedServices;
using Meziantou.AspNetCore.BundleTagHelpers;
using System.Security.Claims;
using BTCPayServer.Crowdfund;
using BTCPayServer.Hubs;
using BTCPayServer.Payments.Changelly;
using BTCPayServer.Payments.Lightning;
using BTCPayServer.Security;
@ -185,7 +183,7 @@ namespace BTCPayServer.Hosting
services.AddSingleton<IHostedService, InvoiceWatcher>();
services.AddSingleton<IHostedService, RatesHostedService>();
services.AddSingleton<IHostedService, BackgroundJobSchedulerHostedService>();
services.AddSingleton<IHostedService, CrowdfundHubStreamer>();
services.AddSingleton<IHostedService, AppHubStreamer>();
services.AddSingleton<IBackgroundJobClient, BackgroundJobClient>();
services.AddTransient<IConfigureOptions<MvcOptions>, BTCPayClaimsFilter>();

View File

@ -34,9 +34,9 @@ using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Mvc.Cors.Internal;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using System.Net;
using BTCPayServer.Hubs;
using Meziantou.AspNetCore.BundleTagHelpers;
using BTCPayServer.Security;
using BTCPayServer.Services.Apps;
namespace BTCPayServer.Hosting
{
@ -164,7 +164,7 @@ namespace BTCPayServer.Hosting
app.UseAuthentication();
app.UseSignalR(route =>
{
route.MapHub<CrowdfundHub>("/apps/crowdfund/hub");
route.MapHub<AppHub>("/apps/hub");
});
app.UseWebSockets();
app.UseStatusCodePages();

View File

@ -31,7 +31,7 @@ namespace BTCPayServer.Models.AppViewModels
public string DisqusShortname { get; set; }
public bool AnimationsEnabled { get; set; }
public int ResetEveryAmount { get; set; }
public string ResetEvery { get; set; }
public bool NeverReset { get; set; }
public Dictionary<string, int> PerkCount { get; set; }

View File

@ -6,9 +6,9 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
namespace BTCPayServer.Hubs
namespace BTCPayServer.Services.Apps
{
public class CrowdfundHub: Hub
public class AppHub: Hub
{
public const string InvoiceCreated = "InvoiceCreated";
public const string PaymentReceived = "PaymentReceived";
@ -16,7 +16,7 @@ namespace BTCPayServer.Hubs
public const string InvoiceError = "InvoiceError";
private readonly AppsPublicController _AppsPublicController;
public CrowdfundHub(AppsPublicController appsPublicController)
public AppHub(AppsPublicController appsPublicController)
{
_AppsPublicController = appsPublicController;
}

View File

@ -8,7 +8,6 @@ using System.Threading.Tasks;
using BTCPayServer.Controllers;
using BTCPayServer.Data;
using BTCPayServer.Events;
using BTCPayServer.Hubs;
using BTCPayServer.Logging;
using BTCPayServer.Models.AppViewModels;
using BTCPayServer.Payments;
@ -22,18 +21,18 @@ using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using NBitcoin;
namespace BTCPayServer.Crowdfund
namespace BTCPayServer.Services.Apps
{
public class CrowdfundHubStreamer : IHostedService
public class AppHubStreamer : IHostedService
{
private readonly EventAggregator _EventAggregator;
private readonly IHubContext<CrowdfundHub> _HubContext;
private readonly IHubContext<AppHub> _HubContext;
private List<IEventAggregatorSubscription> _Subscriptions;
private CancellationTokenSource _Cts;
public CrowdfundHubStreamer(EventAggregator eventAggregator,
IHubContext<CrowdfundHub> hubContext)
public AppHubStreamer(EventAggregator eventAggregator,
IHubContext<AppHub> hubContext)
{
_EventAggregator = eventAggregator;
_HubContext = hubContext;
@ -44,7 +43,7 @@ namespace BTCPayServer.Crowdfund
if (invoiceEvent.Name == InvoiceEvent.ReceivedPayment)
{
var data = invoiceEvent.Payment.GetCryptoPaymentData();
await _HubContext.Clients.Group(appId).SendCoreAsync(CrowdfundHub.PaymentReceived, new object[]
await _HubContext.Clients.Group(appId).SendCoreAsync(AppHub.PaymentReceived, new object[]
{
data.GetValue(),
invoiceEvent.Payment.GetCryptoCode(),

View File

@ -6,7 +6,6 @@ using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using BTCPayServer.Crowdfund;
using BTCPayServer.Data;
using BTCPayServer.Filters;
using BTCPayServer.Models;
@ -151,7 +150,7 @@ namespace BTCPayServer.Services.Apps
ResetEveryAmount = settings.ResetEveryAmount,
DisplayPerksRanking = settings.DisplayPerksRanking,
PerkCount = perkCount,
ResetEvery = Enum.GetName(typeof(CrowdfundResetEvery), settings.ResetEvery),
NeverReset = settings.ResetEvery == CrowdfundResetEvery.Never,
CurrencyData = _Currencies.GetCurrencyData(settings.TargetCurrency, true),
Info = new ViewCrowdfundViewModel.CrowdfundInfo()
{

View File

@ -1,6 +1,4 @@
@using BTCPayServer.Crowdfund
@using BTCPayServer.Hubs
@addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers
@addTagHelper *, Meziantou.AspNetCore.BundleTagHelpers
@model UpdateCrowdfundViewModel
@{
ViewData["Title"] = "Update Crowdfund";

View File

@ -37,7 +37,7 @@
{
<span class="mt-3">
<span class="h5">@Model.TargetAmount @Model.TargetCurrency</span>
@if (Model.ResetEveryAmount > 0 && Model.ResetEvery != nameof(CrowdfundResetEvery.Never))
@if (Model.ResetEveryAmount > 0 && !Model.NeverReset)
{
<span> Dynamic</span>
}

View File

@ -1,7 +1,7 @@
var hubListener = function(){
var connection = new signalR.HubConnectionBuilder().withUrl("/apps/crowdfund/hub").build();
var connection = new signalR.HubConnectionBuilder().withUrl("/apps/hub").build();
connection.onclose(function(){
eventAggregator.$emit("connection-lost");