using System;
using System.Threading.Tasks;
using Dpz.Core.Public.ViewModel;
using Dpz.Core.Service;
using Dpz.Core.Service.RepositoryService;
namespace Dpz.Core.Web.Library.Hub
{
public class BarrageHub:Microsoft.AspNetCore.SignalR.Hub
{
private readonly IBarrageService _barrageService;
public BarrageHub(IBarrageService barrageService)
{
_barrageService = barrageService;
}
public async Task Send(VmBarrage barrage)
{
if (string.IsNullOrEmpty(barrage?.Text)) return;
await Clients.All.SendCoreAsync("ReceiveMessage", new object[] {barrage});
barrage.SendTime = DateTime.Now;
await _barrageService.AddBarrageAsync(barrage);
}
}
}