39 lines
No EOL
1.2 KiB
C#
39 lines
No EOL
1.2 KiB
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNet.SignalR;
|
|
using Microsoft.AspNet.SignalR.Hubs;
|
|
using Shuttle.Api.CommunicationDTO.IdentityDTO;
|
|
using Shuttle.Api.ServerAPI;
|
|
using Shuttle.Servers.Managers.Clients;
|
|
|
|
namespace Shuttle.Servers.Hubs
|
|
{
|
|
[HubName(ServerConstants.ClientHubName)]
|
|
public class ClientHub : Hub, IIdentificationRoutes
|
|
{
|
|
private readonly IClientManager _clientConnectionsManager;
|
|
|
|
public ClientHub(IClientManager clientManager)
|
|
{
|
|
_clientConnectionsManager = clientManager ?? throw new ArgumentNullException(nameof(clientManager));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called from the client to the server
|
|
/// </summary>
|
|
public Task RegisterClientIdentity(AdobeAppInfo appInfo)
|
|
{
|
|
return Task.Run(() =>
|
|
{
|
|
string connectionId = this.Context.ConnectionId;
|
|
_clientConnectionsManager.RegisterConnection(connectionId, appInfo);
|
|
});
|
|
}
|
|
|
|
public override Task OnDisconnected(bool stopCalled)
|
|
{
|
|
_clientConnectionsManager.UnregisterConnection(this.Context.ConnectionId, stopCalled);
|
|
return base.OnDisconnected(stopCalled);
|
|
}
|
|
}
|
|
} |