diff options
| author | JP Dillingham <jp@dillingham.me> | 2022-10-19 23:34:14 -0500 |
|---|---|---|
| committer | JP Dillingham <jp@dillingham.me> | 2022-10-19 23:34:14 -0500 |
| commit | 595a91654b9b8c7ea9fa564b52769b39cc95d69e (patch) | |
| tree | 830380f9c982febc20fba4d763b3e1b0143e79d2 /src/slskd/Network/API | |
| parent | bd4290639406a1ffaa6143fa2cdebc8223eaace0 (diff) | |
| download | slskd-595a91654b9b8c7ea9fa564b52769b39cc95d69e.tar.gz | |
wip
Diffstat (limited to 'src/slskd/Network/API')
| -rw-r--r-- | src/slskd/Network/API/Hubs/NetworkHub.cs | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/src/slskd/Network/API/Hubs/NetworkHub.cs b/src/slskd/Network/API/Hubs/NetworkHub.cs index f79fecf2..cf1dc463 100644 --- a/src/slskd/Network/API/Hubs/NetworkHub.cs +++ b/src/slskd/Network/API/Hubs/NetworkHub.cs @@ -28,32 +28,37 @@ namespace slskd.Network public static readonly string RequestFile = "REQUEST_FILE"; public static readonly string RequestFileInfo = "REQUEST_FILE_INFO"; public static readonly string AuthenticationChallenge = "AUTHENTICATION_CHALLENGE"; - public static readonly string AuthenticationChallengeAccepted = "AUTHENTICATION_CHALLENGE_ACCEPTED"; - public static readonly string AuthenticationChallengeRejected = "AUTHENTICATION_CHALLENGE_REJECTED"; } - /// <summary> - /// Extension methods for the network SignalR hub. - /// </summary> - public static class NetworkHubExtensions - { - public static Task RequestFileAsync(this IHubContext<NetworkHub> hub, string agent, string filename, Guid id) - { - // todo: how to send this to the specified agent? - return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFile, filename, id); - } + ///// <summary> + ///// Extension methods for the network SignalR hub. + ///// </summary> + //public static class NetworkHubExtensions + //{ + // public static Task RequestFileAsync(this IHubContext<NetworkHub> hub, string agent, string filename, Guid id) + // { + // // todo: how to send this to the specified agent? + // return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFile, filename, id); + // } - public static Task RequestFileInfoAsync(this IHubContext<NetworkHub> hub, string agent, string filename, Guid id) - { - return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFileInfo, filename, id); - } + // public static Task RequestFileInfoAsync(this IHubContext<NetworkHub> hub, string agent, string filename, Guid id) + // { + // return hub.Clients.All.SendAsync(NetworkHubMethods.RequestFileInfo, filename, id); + // } + //} + + public interface INetworkHub + { + Task RequestFile(string filename, Guid id); + Task RequestFileInfo(string filename, Guid id); + Task AuthenticationChallenge(string token); } /// <summary> /// The network SignalR hub. /// </summary> [Authorize] - public class NetworkHub : Hub + public class NetworkHub : Hub<INetworkHub> { public NetworkHub( INetworkService networkService) @@ -67,7 +72,7 @@ namespace slskd.Network public override async Task OnConnectedAsync() { Log.Information("Agent connection {Id} established. Sending authentication challenge...", Context.ConnectionId); - await Clients.Caller.SendAsync(NetworkHubMethods.AuthenticationChallenge, Network.GenerateAuthenticationChallengeToken(Context.ConnectionId)); + await Clients.Caller.AuthenticationChallenge(Network.GenerateAuthenticationChallengeToken(Context.ConnectionId)); } public override Task OnDisconnectedAsync(Exception exception) |
