You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
822 B
34 lines
822 B
using Infrastructure.Events;
|
|
using Infrastructure.Extensions;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using Platform.Services;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Platform.EventHandlers
|
|
{
|
|
public class BaseEventHandler
|
|
{
|
|
private readonly IHubContext<IoTCenterHub> _hub;
|
|
|
|
public BaseEventHandler(IHubContext<IoTCenterHub> hub)
|
|
{
|
|
this._hub = hub;
|
|
}
|
|
|
|
public void Notify<T>(BaseEvent<T> message)
|
|
{
|
|
Task.Run(() =>
|
|
{
|
|
try
|
|
{
|
|
_hub.ServerToClient($"{typeof(T).Name}{message.Arg}", message.Data, "page", null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ex.PrintStack();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
} |