Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed the way hubs are mapped in routing host.

  • Loading branch information...
commit b438d4cb40847bb1938478470f831a80aceb5005 1 parent 149caf4
@davidfowl davidfowl authored
View
15 SignalR.Hosting.Common/Routing/RouteManager.cs
@@ -1,6 +1,6 @@
using System;
using System.Collections.Generic;
-using SignalR.Infrastructure;
+using SignalR.Hubs;
namespace SignalR.Hosting.Common.Routing
{
@@ -8,6 +8,7 @@ public class RouteManager
{
private readonly IDependencyResolver _resolver;
private readonly Dictionary<string, Type> _connectionMapping = new Dictionary<string, Type>();
+ private string _hubPath;
public RouteManager(IDependencyResolver resolver)
{
@@ -22,6 +23,11 @@ public RouteManager(IDependencyResolver resolver)
}
}
+ public void MapHubs(string path)
+ {
+ _hubPath = path;
+ }
+
public bool TryGetConnection(Uri uri, out PersistentConnection connection)
{
return TryGetConnection(uri.LocalPath, out connection);
@@ -31,6 +37,13 @@ public bool TryGetConnection(string path, out PersistentConnection connection)
{
connection = null;
+ if (!String.IsNullOrEmpty(_hubPath) &&
+ path.StartsWith(_hubPath, StringComparison.OrdinalIgnoreCase))
+ {
+ connection = new HubDispatcher(_hubPath);
+ return true;
+ }
+
foreach (var pair in _connectionMapping)
{
// If the url matches then create the connection type
View
28 SignalR.Hosting.Common/RoutingHost.cs
@@ -1,7 +1,4 @@
-using System;
-using SignalR.Hosting.Common.Routing;
-using SignalR.Hubs;
-using SignalR.Infrastructure;
+using SignalR.Hosting.Common.Routing;
namespace SignalR.Hosting.Common
{
@@ -20,19 +17,26 @@ public RoutingHost(IDependencyResolver resolver)
_routeManager = new RouteManager(resolver);
}
- public void MapConnection<TConnection>(string path) where TConnection : PersistentConnection
+ public RoutingHost MapHubs()
{
- _routeManager.MapConnection<TConnection>(path);
+ return MapHubs("/signalr");
+ }
+
+ public RoutingHost MapHubs(string path)
+ {
+ _routeManager.MapHubs(path);
+
+ return this;
}
- public virtual bool TryGetConnection(string path, out PersistentConnection connection)
+ public RoutingHost MapConnection<TConnection>(string path) where TConnection : PersistentConnection
{
- if (path.StartsWith("/signalr", StringComparison.OrdinalIgnoreCase))
- {
- connection = new HubDispatcher("/signalr");
- return true;
- }
+ _routeManager.MapConnection<TConnection>(path);
+ return this;
+ }
+ public bool TryGetConnection(string path, out PersistentConnection connection)
+ {
return _routeManager.TryGetConnection(path, out connection);
}
}
View
1  SignalR.Tests/DisconnectFacts.cs
@@ -39,6 +39,7 @@ public void DisconnectFiresForPersistentConnectionWhenClientGoesAway()
public void DisconnectFiresForHubsWhenConnectionGoesAway()
{
var host = new MemoryHost();
+ host.MapHubs();
var configurationManager = host.DependencyResolver.Resolve<IConfigurationManager>();
configurationManager.DisconnectTimeout = TimeSpan.Zero;
configurationManager.HeartBeatInterval = TimeSpan.FromSeconds(5);
Please sign in to comment.
Something went wrong with that request. Please try again.