mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 02:37:08 -07:00
SignalR/Nancy/Owin/Mono
This commit is contained in:
parent
45b4972091
commit
87a5dc7869
40 changed files with 2375 additions and 76 deletions
39
NzbDrone.Api/SignalR/BasicResourceConnection.cs
Normal file
39
NzbDrone.Api/SignalR/BasicResourceConnection.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.SignalR;
|
||||
using NLog;
|
||||
using NzbDrone.Common.Messaging;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
|
||||
namespace NzbDrone.Api.SignalR
|
||||
{
|
||||
public abstract class BasicResourceConnection<T> :
|
||||
NzbDronePersistentConnection,
|
||||
IHandleAsync<ModelEvent<T>>
|
||||
where T : ModelBase
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
public BasicResourceConnection()
|
||||
{
|
||||
_logger = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
|
||||
protected override Task OnConnected(IRequest request, string connectionId)
|
||||
{
|
||||
_logger.Debug("SignalR client connected. ID:{0}", connectionId);
|
||||
return base.OnConnected(request, connectionId);
|
||||
}
|
||||
|
||||
public override Task ProcessRequest(Microsoft.AspNet.SignalR.Hosting.HostContext context)
|
||||
{
|
||||
_logger.Debug("Request: {0}", context);
|
||||
return base.ProcessRequest(context);
|
||||
}
|
||||
|
||||
public void HandleAsync(ModelEvent<T> message)
|
||||
{
|
||||
Connection.Broadcast(message);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue