Skip to content

Commit 1d050cd

Browse files
committed
SignalR Allow returns from all single client proxies
- #41763 (comment)
1 parent 750000f commit 1d050cd

File tree

5 files changed

+6
-23
lines changed

5 files changed

+6
-23
lines changed

src/SignalR/server/Core/src/IHubClients`T.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public interface IHubClients<T>
1414
/// </summary>
1515
/// <param name="connectionId">The connection ID.</param>
1616
/// <returns>A client caller.</returns>
17-
T Single(string connectionId) => throw new NotImplementedException();
17+
T Single(string connectionId) => Client(connectionId);
1818

1919
/// <summary>
2020
/// Gets a <typeparamref name="T" /> that can be used to invoke methods on all clients connected to the hub.

src/SignalR/server/Core/src/Internal/HubClients.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public HubClients(HubLifetimeManager<THub> lifetimeManager)
1515

1616
public ISingleClientProxy Single(string connectionId)
1717
{
18-
return new SingleClientProxyWithInvoke<THub>(_lifetimeManager, connectionId);
18+
return new SingleClientProxy<THub>(_lifetimeManager, connectionId);
1919
}
2020

2121
public IClientProxy All { get; }

src/SignalR/server/Core/src/Internal/HubClients`T.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public HubClients(HubLifetimeManager<THub> lifetimeManager)
1717

1818
public T Single(string connectionId)
1919
{
20-
return TypedClientBuilder<T>.Build(new SingleClientProxyWithInvoke<THub>(_lifetimeManager, connectionId));
20+
return TypedClientBuilder<T>.Build(new SingleClientProxy<THub>(_lifetimeManager, connectionId));
2121
}
2222

2323
public T AllExcept(IReadOnlyList<string> excludedConnectionIds)

src/SignalR/server/Core/src/Internal/Proxies.cs

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,6 @@ public Task SendCoreAsync(string method, object?[] args, CancellationToken cance
122122
}
123123
}
124124

125-
internal sealed class SingleClientProxy<THub> : IClientProxy where THub : Hub
126-
{
127-
private readonly string _connectionId;
128-
private readonly HubLifetimeManager<THub> _lifetimeManager;
129-
130-
public SingleClientProxy(HubLifetimeManager<THub> lifetimeManager, string connectionId)
131-
{
132-
_lifetimeManager = lifetimeManager;
133-
_connectionId = connectionId;
134-
}
135-
136-
public Task SendCoreAsync(string method, object?[] args, CancellationToken cancellationToken = default)
137-
{
138-
return _lifetimeManager.SendConnectionAsync(_connectionId, method, args, cancellationToken);
139-
}
140-
}
141-
142125
internal sealed class MultipleClientProxy<THub> : IClientProxy where THub : Hub
143126
{
144127
private readonly HubLifetimeManager<THub> _lifetimeManager;
@@ -156,12 +139,12 @@ public Task SendCoreAsync(string method, object?[] args, CancellationToken cance
156139
}
157140
}
158141

159-
internal sealed class SingleClientProxyWithInvoke<THub> : ISingleClientProxy where THub : Hub
142+
internal sealed class SingleClientProxy<THub> : ISingleClientProxy where THub : Hub
160143
{
161144
private readonly string _connectionId;
162145
private readonly HubLifetimeManager<THub> _lifetimeManager;
163146

164-
public SingleClientProxyWithInvoke(HubLifetimeManager<THub> lifetimeManager, string connectionId)
147+
public SingleClientProxy(HubLifetimeManager<THub> lifetimeManager, string connectionId)
165148
{
166149
_lifetimeManager = lifetimeManager;
167150
_connectionId = connectionId;

src/SignalR/server/SignalR/test/ClientProxyTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public async Task SingleClientProxyWithInvoke_ThrowsNotSupported()
212212
{
213213
var hubLifetimeManager = new EmptyHubLifetimeManager<FakeHub>();
214214

215-
var proxy = new SingleClientProxyWithInvoke<FakeHub>(hubLifetimeManager, "");
215+
var proxy = new SingleClientProxy<FakeHub>(hubLifetimeManager, "");
216216
var ex = await Assert.ThrowsAsync<NotImplementedException>(async () => await proxy.InvokeAsync<int>("method")).DefaultTimeout();
217217
Assert.Equal("EmptyHubLifetimeManager`1 does not support client return values.", ex.Message);
218218
}

0 commit comments

Comments
 (0)