Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Throw if CreateProxy called after the connection is started.

  • Loading branch information...
commit 89eb8e492c6362f32b375845eb14fda229011a06 1 parent 23dd63a
@davidfowl davidfowl authored
Showing with 23 additions and 0 deletions.
  1. +5 −0 SignalR.Client/Hubs/HubConnection.cs
  2. +18 −0 SignalR.Tests/HubFacts.cs
View
5 SignalR.Client/Hubs/HubConnection.cs
@@ -91,6 +91,11 @@ protected override string OnSending()
/// <returns>A <see cref="IHubProxy"/></returns>
public IHubProxy CreateProxy(string hubName)
{
+ if (State != ConnectionState.Disconnected)
+ {
+ throw new InvalidOperationException("Proxies cannot be added after the connection has been started.");
+ }
+
HubProxy hubProxy;
if (!_hubs.TryGetValue(hubName, out hubProxy))
{
View
18 SignalR.Tests/HubFacts.cs
@@ -254,5 +254,23 @@ public void DynamicInvokeTest()
Assert.True(wh.WaitOne(TimeSpan.FromSeconds(5)));
connection.Stop();
}
+
+ [Fact]
+ public void CreateProxyAfterConnectionStartsThrows()
+ {
+ var host = new MemoryHost();
+ host.MapHubs();
+ var connection = new Client.Hubs.HubConnection("http://site/");
+
+ try
+ {
+ connection.Start(host).Wait();
+ Assert.Throws<InvalidOperationException>(() => connection.CreateProxy("demo"));
+ }
+ finally
+ {
+ connection.Stop();
+ }
+ }
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.