diff --git a/src/Microsoft.AspNet.SignalR.Core/AuthorizeAttribute.cs b/src/Microsoft.AspNet.SignalR.Core/AuthorizeAttribute.cs
deleted file mode 100644
index 05caef0a0..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/AuthorizeAttribute.cs
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using System.Security.Principal;
-using Microsoft.AspNet.SignalR.Hubs;
-
-namespace Microsoft.AspNet.SignalR
-{
- ///
- /// Apply to Hubs and Hub methods to authorize client connections to Hubs and authorize client invocations of Hub methods.
- ///
- [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
- [SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes", Justification = "MVC and WebAPI don't seal their AuthorizeAttributes")]
- public class AuthorizeAttribute : Attribute, IAuthorizeHubConnection, IAuthorizeHubMethodInvocation
- {
- private string _roles;
- private string[] _rolesSplit = new string[0];
- private string _users;
- private string[] _usersSplit = new string[0];
-
- [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields", Justification = "Already somewhat represented by set-only RequiredOutgoing property.")]
- protected bool? _requireOutgoing;
-
- ///
- /// Set to false to apply authorization only to the invocations of any of the Hub's server-side methods.
- /// This property only affects attributes applied to the Hub class.
- /// This property cannot be read.
- ///
- [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Must be property because this is an attribute parameter.")]
- public bool RequireOutgoing
- {
- // It is impossible to tell here whether the attribute is being applied to a method or class. This makes
- // it impossible to determine whether the value should be true or false when _requireOutgoing is null.
- // It is also impossible to have a Nullable attribute parameter type.
- get { throw new NotImplementedException(Resources.Error_DoNotReadRequireOutgoing); }
- set { _requireOutgoing = value; }
- }
-
- ///
- /// Gets or sets the user roles.
- ///
- public string Roles
- {
- get { return _roles ?? String.Empty; }
- set
- {
- _roles = value;
- _rolesSplit = SplitString(value);
- }
- }
-
- ///
- /// Gets or sets the authorized users.
- ///
- public string Users
- {
- get { return _users ?? String.Empty; }
- set
- {
- _users = value;
- _usersSplit = SplitString(value);
- }
- }
-
- ///
- /// Determines whether client is authorized to connect to .
- ///
- /// Description of the hub client is attempting to connect to.
- /// The (re)connect request from the client.
- /// true if the caller is authorized to connect to the hub; otherwise, false.
- public virtual bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request)
- {
- if (request == null)
- {
- throw new ArgumentNullException("request");
- }
-
- // If RequireOutgoing is explicitly set to false, authorize all connections.
- if (_requireOutgoing.HasValue && !_requireOutgoing.Value)
- {
- return true;
- }
-
- return UserAuthorized(request.User);
- }
-
- ///
- /// Determines whether client is authorized to invoke the method.
- ///
- /// An providing details regarding the method invocation.
- /// Indicates whether the interface instance is an attribute applied directly to a method.
- /// true if the caller is authorized to invoke the method; otherwise, false.
- public virtual bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod)
- {
- if (hubIncomingInvokerContext == null)
- {
- throw new ArgumentNullException("hubIncomingInvokerContext");
- }
-
- // It is impossible to require outgoing auth at the method level with SignalR's current design.
- // Even though this isn't the stage at which outgoing auth would be applied, we want to throw a runtime error
- // to indicate when the attribute is being used with obviously incorrect expectations.
-
- // We must explicitly check if _requireOutgoing is true since it is a Nullable type.
- if (appliesToMethod && (_requireOutgoing == true))
- {
- throw new ArgumentException(Resources.Error_MethodLevelOutgoingAuthorization);
- }
-
- return UserAuthorized(hubIncomingInvokerContext.Hub.Context.User);
- }
-
- ///
- /// When overridden, provides an entry point for custom authorization checks.
- /// Called by and .
- ///
- /// The for the client being authorize
- /// true if the user is authorized, otherwise, false
- protected virtual bool UserAuthorized(IPrincipal user)
- {
- if (user == null)
- {
- return false;
- }
-
- if (!user.Identity.IsAuthenticated)
- {
- return false;
- }
-
- if (_usersSplit.Length > 0 && !_usersSplit.Contains(user.Identity.Name, StringComparer.OrdinalIgnoreCase))
- {
- return false;
- }
-
- if (_rolesSplit.Length > 0 && !_rolesSplit.Any(user.IsInRole))
- {
- return false;
- }
-
- return true;
- }
-
- private static string[] SplitString(string original)
- {
- if (String.IsNullOrEmpty(original))
- {
- return new string[0];
- }
-
- var split = from piece in original.Split(',')
- let trimmed = piece.Trim()
- where !String.IsNullOrEmpty(trimmed)
- select trimmed;
- return split.ToArray();
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Configuration/ConfigurationExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Configuration/ConfigurationExtensions.cs
deleted file mode 100644
index 630fad897..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Configuration/ConfigurationExtensions.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Configuration
-{
- internal static class ConfigurationExtensions
- {
- public const int MissedTimeoutsBeforeClientReconnect = 2;
- public const int HeartBeatsPerKeepAlive = 2;
- public const int HeartBeatsPerDisconnectTimeout = 6;
-
- ///
- /// The amount of time the client should wait without seeing a keep alive before trying to reconnect.
- ///
- public static TimeSpan? KeepAliveTimeout(this IConfigurationManager config)
- {
- if (config.KeepAlive != null)
- {
- return TimeSpan.FromTicks(config.KeepAlive.Value.Ticks * MissedTimeoutsBeforeClientReconnect);
- }
- else
- {
- return null;
- }
- }
-
- ///
- /// The interval between successively checking connection states.
- ///
- public static TimeSpan HeartbeatInterval(this IConfigurationManager config)
- {
- if (config.KeepAlive != null)
- {
- return TimeSpan.FromTicks(config.KeepAlive.Value.Ticks / HeartBeatsPerKeepAlive);
- }
- else
- {
- // If KeepAlives are disabled, have the heartbeat run at the same rate it would if the KeepAlive was
- // kept at the default value.
- return TimeSpan.FromTicks(config.DisconnectTimeout.Ticks / HeartBeatsPerDisconnectTimeout);
- }
- }
-
- ///
- /// The amount of time a Topic should stay in memory after its last subscriber is removed.
- ///
- ///
- ///
- public static TimeSpan TopicTtl(this IConfigurationManager config)
- {
- // If the deep-alive is disabled, don't take it into account when calculating the topic TTL.
- var keepAliveTimeout = config.KeepAliveTimeout() ?? TimeSpan.Zero;
-
- // Keep topics alive for twice as long as we let connections to reconnect. (The DisconnectTimeout)
- // Also add twice the keep-alive timeout since clients might take a while to notice they are disconnected.
- // This should be a very conservative estimate for how long we must wait before considering a topic dead.
- return TimeSpan.FromTicks((config.DisconnectTimeout.Ticks + keepAliveTimeout.Ticks) * 2);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Configuration/DefaultConfigurationManager.cs b/src/Microsoft.AspNet.SignalR.Core/Configuration/DefaultConfigurationManager.cs
deleted file mode 100644
index af49f1978..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Configuration/DefaultConfigurationManager.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Configuration
-{
- public class DefaultConfigurationManager : IConfigurationManager
- {
- // The below effectively sets the minimum heartbeat to once per second.
- // if _minimumKeepAlive != 2 seconds, update the ArguementOutOfRanceExceptionMessage below
- private static readonly TimeSpan _minimumKeepAlive = TimeSpan.FromSeconds(2);
-
- // if _minimumKeepAlivesPerDisconnectTimeout != 3, update the ArguementOutOfRanceExceptionMessage below
- private const int _minimumKeepAlivesPerDisconnectTimeout = 3;
-
- // if _minimumDisconnectTimeout != 6 seconds, update the ArguementOutOfRanceExceptionMessage below
- private static readonly TimeSpan _minimumDisconnectTimeout = TimeSpan.FromTicks(_minimumKeepAlive.Ticks * _minimumKeepAlivesPerDisconnectTimeout);
-
- private bool _keepAliveConfigured;
- private TimeSpan? _keepAlive;
- private TimeSpan _disconnectTimeout;
-
- public DefaultConfigurationManager()
- {
- ConnectionTimeout = TimeSpan.FromSeconds(110);
- DisconnectTimeout = TimeSpan.FromSeconds(30);
- DefaultMessageBufferSize = 1000;
- }
-
- // TODO: Should we guard against negative TimeSpans here like everywhere else?
- public TimeSpan ConnectionTimeout
- {
- get;
- set;
- }
-
- public TimeSpan DisconnectTimeout
- {
- get
- {
- return _disconnectTimeout;
- }
- set
- {
- if (value < _minimumDisconnectTimeout)
- {
- throw new ArgumentOutOfRangeException("value", Resources.Error_DisconnectTimeoutMustBeAtLeastSixSeconds);
- }
-
- if (_keepAliveConfigured)
- {
- throw new InvalidOperationException(Resources.Error_DisconnectTimeoutCannotBeConfiguredAfterKeepAlive);
- }
-
- _disconnectTimeout = value;
- _keepAlive = TimeSpan.FromTicks(_disconnectTimeout.Ticks / _minimumKeepAlivesPerDisconnectTimeout);
- }
- }
-
- public TimeSpan? KeepAlive
- {
- get
- {
- return _keepAlive;
- }
- set
- {
- if (value < _minimumKeepAlive)
- {
- throw new ArgumentOutOfRangeException("value", Resources.Error_KeepAliveMustBeGreaterThanTwoSeconds);
- }
-
- if (value > TimeSpan.FromTicks(_disconnectTimeout.Ticks / _minimumKeepAlivesPerDisconnectTimeout))
- {
- throw new ArgumentOutOfRangeException("value", Resources.Error_KeepAliveMustBeNoMoreThanAThirdOfTheDisconnectTimeout);
- }
-
- _keepAlive = value;
- _keepAliveConfigured = true;
- }
- }
-
- public int DefaultMessageBufferSize
- {
- get;
- set;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Configuration/IConfigurationManager.cs b/src/Microsoft.AspNet.SignalR.Core/Configuration/IConfigurationManager.cs
deleted file mode 100644
index 9dd79a241..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Configuration/IConfigurationManager.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Configuration
-{
- ///
- /// Provides access to server configuration.
- ///
- public interface IConfigurationManager
- {
- ///
- /// Gets or sets a representing the amount of time to leave a connection open before timing out.
- ///
- TimeSpan ConnectionTimeout { get; set; }
-
- ///
- /// Gets or sets a representing the amount of time to wait after a connection goes away before raising the disconnect event.
- ///
- TimeSpan DisconnectTimeout { get; set; }
-
- ///
- /// Gets or sets a representing the amount of time between send keep alive messages.
- /// If enabled, this value must be at least two seconds. Set to null to disable.
- ///
- TimeSpan? KeepAlive { get; set; }
-
- ///
- /// Gets of sets the number of messages to buffer for a specific signal.
- ///
- int DefaultMessageBufferSize { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/ConnectionConfiguration.cs b/src/Microsoft.AspNet.SignalR.Core/ConnectionConfiguration.cs
deleted file mode 100644
index eef56241e..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/ConnectionConfiguration.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR
-{
- public class ConnectionConfiguration
- {
- // Resolver isn't set to GlobalHost.DependencyResolver in the ctor because it is lazily created.
- private IDependencyResolver _resolver;
-
- ///
- /// The dependency resolver to use for the hub connection.
- ///
- public IDependencyResolver Resolver
- {
- get { return _resolver ?? GlobalHost.DependencyResolver; }
- set { _resolver = value; }
- }
-
- ///
- /// Determines if browsers can make cross domain requests to SignalR endpoints.
- ///
- public bool EnableCrossDomain { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs
deleted file mode 100644
index 07cc587e1..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/ConnectionExtensions.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR
-{
- public static class ConnectionExtensions
- {
- ///
- /// Sends a message to all connections subscribed to the specified signal. An example of signal may be a
- /// specific connection id.
- ///
- /// The connection
- /// The connectionId to send to.
- /// The value to publish.
- /// The list of connection ids to exclude
- /// A task that represents when the broadcast is complete.
- public static Task Send(this IConnection connection, string connectionId, object value, params string[] excludeConnectionIds)
- {
- if (connection == null)
- {
- throw new ArgumentNullException("connection");
- }
-
- if (string.IsNullOrEmpty(connectionId))
- {
- throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
- }
-
- var message = new ConnectionMessage(PrefixHelper.GetConnectionId(connectionId),
- value,
- PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));
-
- return connection.Send(message);
- }
-
- ///
- /// Broadcasts a value to all connections, excluding the connection ids specified.
- ///
- /// The connection
- /// The value to broadcast.
- /// The list of connection ids to exclude
- /// A task that represents when the broadcast is complete.
- public static Task Broadcast(this IConnection connection, object value, params string[] excludeConnectionIds)
- {
- if (connection == null)
- {
- throw new ArgumentNullException("connection");
- }
-
- var message = new ConnectionMessage(connection.DefaultSignal,
- value,
- PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));
-
- return connection.Send(message);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/ConnectionMessage.cs b/src/Microsoft.AspNet.SignalR.Core/ConnectionMessage.cs
deleted file mode 100644
index 6c632c9f6..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/ConnectionMessage.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR
-{
- ///
- /// A message sent to one more connections.
- ///
- [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes", Justification = "Messags are never compared, just used as data.")]
- public struct ConnectionMessage
- {
- ///
- /// The signal to this message should be sent to. Connections subscribed to this signal
- /// will receive the message payload.
- ///
- public string Signal { get; private set; }
-
- ///
- /// The payload of the message.
- ///
- public object Value { get; private set; }
-
- ///
- /// Represents a list of signals that should be used to filter what connections
- /// receive this message.
- ///
- public IList ExcludedSignals { get; private set; }
-
- public ConnectionMessage(string signal, object value)
- : this(signal, value, ListHelper.Empty)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The signal
- /// The payload of the message
- /// The signals to exclude.
- public ConnectionMessage(string signal, object value, IList excludedSignals)
- : this()
- {
- Signal = signal;
- Value = value;
- ExcludedSignals = excludedSignals;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Cookie.cs b/src/Microsoft.AspNet.SignalR.Core/Cookie.cs
deleted file mode 100644
index b251da93d..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Cookie.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR
-{
- public class Cookie
- {
- public Cookie(string name, string value)
- : this(name, value, String.Empty, String.Empty)
- {
-
- }
-
- public Cookie(string name, string value, string domain, string path)
- {
- Name = name;
- Value = value;
- Domain = domain;
- Path = path;
- }
-
- public string Name { get; private set; }
- public string Domain { get; private set; }
- public string Path { get; private set; }
- public string Value { get; private set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/DefaultDependencyResolver.cs b/src/Microsoft.AspNet.SignalR.Core/DefaultDependencyResolver.cs
deleted file mode 100644
index da8cb14fc..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/DefaultDependencyResolver.cs
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Linq;
-using System.Threading;
-using Microsoft.AspNet.SignalR.Configuration;
-using Microsoft.AspNet.SignalR.Hubs;
-using Microsoft.AspNet.SignalR.Infrastructure;
-using Microsoft.AspNet.SignalR.Json;
-using Microsoft.AspNet.SignalR.Messaging;
-using Microsoft.AspNet.SignalR.Tracing;
-using Microsoft.AspNet.SignalR.Transports;
-
-namespace Microsoft.AspNet.SignalR
-{
- public class DefaultDependencyResolver : IDependencyResolver
- {
- private readonly Dictionary>> _resolvers = new Dictionary>>();
- private readonly HashSet _trackedDisposables = new HashSet();
- private int _disposed;
-
- [SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "It's easiest")]
- public DefaultDependencyResolver()
- {
- RegisterDefaultServices();
-
- // Hubs
- RegisterHubExtensions();
- }
-
- [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "The resolver is the class that does the most coupling by design.")]
- [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "The resolver disposes dependencies on Dispose.")]
- private void RegisterDefaultServices()
- {
- var traceManager = new Lazy(() => new TraceManager());
- Register(typeof(ITraceManager), () => traceManager.Value);
-
- var serverIdManager = new ServerIdManager();
- Register(typeof(IServerIdManager), () => serverIdManager);
-
- var serverMessageHandler = new Lazy(() => new ServerCommandHandler(this));
- Register(typeof(IServerCommandHandler), () => serverMessageHandler.Value);
-
- var newMessageBus = new Lazy(() => new MessageBus(this));
- Register(typeof(IMessageBus), () => newMessageBus.Value);
-
- var stringMinifier = new Lazy(() => new StringMinifier());
- Register(typeof(IStringMinifier), () => stringMinifier.Value);
-
- var serializer = new Lazy();
- Register(typeof(IJsonSerializer), () => serializer.Value);
-
- var transportManager = new Lazy(() => new TransportManager(this));
- Register(typeof(ITransportManager), () => transportManager.Value);
-
- var configurationManager = new DefaultConfigurationManager();
- Register(typeof(IConfigurationManager), () => configurationManager);
-
- var transportHeartbeat = new Lazy(() => new TransportHeartbeat(this));
- Register(typeof(ITransportHeartbeat), () => transportHeartbeat.Value);
-
- var connectionManager = new Lazy(() => new ConnectionManager(this));
- Register(typeof(IConnectionManager), () => connectionManager.Value);
-
- var ackHandler = new Lazy();
- Register(typeof(IAckHandler), () => ackHandler.Value);
-
- var perfCounterWriter = new Lazy(() => new PerformanceCounterManager(this));
- Register(typeof(IPerformanceCounterManager), () => perfCounterWriter.Value);
-
- var protectedData = new DefaultProtectedData();
- Register(typeof(IProtectedData), () => protectedData);
- }
-
- private void RegisterHubExtensions()
- {
- var methodDescriptorProvider = new Lazy();
- Register(typeof(IMethodDescriptorProvider), () => methodDescriptorProvider.Value);
-
- var hubDescriptorProvider = new Lazy(() => new ReflectedHubDescriptorProvider(this));
- Register(typeof(IHubDescriptorProvider), () => hubDescriptorProvider.Value);
-
- var parameterBinder = new Lazy();
- Register(typeof(IParameterResolver), () => parameterBinder.Value);
-
- var activator = new Lazy(() => new DefaultHubActivator(this));
- Register(typeof(IHubActivator), () => activator.Value);
-
- var hubManager = new Lazy(() => new DefaultHubManager(this));
- Register(typeof(IHubManager), () => hubManager.Value);
-
- var proxyGenerator = new Lazy(() => new DefaultJavaScriptProxyGenerator(this));
- Register(typeof(IJavaScriptProxyGenerator), () => proxyGenerator.Value);
-
- var requestParser = new Lazy();
- Register(typeof(IHubRequestParser), () => requestParser.Value);
-
- var assemblyLocator = new Lazy(() => new DefaultAssemblyLocator());
- Register(typeof(IAssemblyLocator), () => assemblyLocator.Value);
-
- // Setup the default hub pipeline
- var dispatcher = new Lazy(() => new HubPipeline().AddModule(new AuthorizeModule()));
- Register(typeof(IHubPipeline), () => dispatcher.Value);
- Register(typeof(IHubPipelineInvoker), () => dispatcher.Value);
- }
-
- public virtual object GetService(Type serviceType)
- {
- if (serviceType == null)
- {
- throw new ArgumentNullException("serviceType");
- }
-
- IList> activators;
- if (_resolvers.TryGetValue(serviceType, out activators))
- {
- if (activators.Count == 0)
- {
- return null;
- }
- if (activators.Count > 1)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_MultipleActivatorsAreaRegisteredCallGetServices, serviceType.FullName));
- }
- return Track(activators[0]);
- }
- return null;
- }
-
- public virtual IEnumerable GetServices(Type serviceType)
- {
- IList> activators;
- if (_resolvers.TryGetValue(serviceType, out activators))
- {
- if (activators.Count == 0)
- {
- return null;
- }
- return activators.Select(Track).ToList();
- }
- return null;
- }
-
- public virtual void Register(Type serviceType, Func activator)
- {
- IList> activators;
- if (!_resolvers.TryGetValue(serviceType, out activators))
- {
- activators = new List>();
- _resolvers.Add(serviceType, activators);
- }
- else
- {
- activators.Clear();
- }
- activators.Add(activator);
- }
-
- public virtual void Register(Type serviceType, IEnumerable> activators)
- {
- if (activators == null)
- {
- throw new ArgumentNullException("activators");
- }
-
- IList> list;
- if (!_resolvers.TryGetValue(serviceType, out list))
- {
- list = new List>();
- _resolvers.Add(serviceType, list);
- }
- else
- {
- list.Clear();
- }
- foreach (var a in activators)
- {
- list.Add(a);
- }
- }
-
- private object Track(Func creator)
- {
- object obj = creator();
-
- if (_disposed == 0)
- {
- var disposable = obj as IDisposable;
- if (disposable != null)
- {
- lock (_trackedDisposables)
- {
- if (_disposed == 0)
- {
- _trackedDisposables.Add(disposable);
- }
- }
- }
- }
-
- return obj;
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Interlocked.Exchange(ref _disposed, 1) == 0)
- {
- lock (_trackedDisposables)
- {
- foreach (var d in _trackedDisposables)
- {
- d.Dispose();
- }
-
- _trackedDisposables.Clear();
- }
- }
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/DependencyResolverExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/DependencyResolverExtensions.cs
deleted file mode 100644
index d579634b1..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/DependencyResolverExtensions.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-
-namespace Microsoft.AspNet.SignalR
-{
- public static class DependencyResolverExtensions
- {
- public static T Resolve(this IDependencyResolver resolver)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- return (T)resolver.GetService(typeof(T));
- }
-
- public static object Resolve(this IDependencyResolver resolver, Type type)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- if (type == null)
- {
- throw new ArgumentNullException("type");
- }
-
- return resolver.GetService(type);
- }
-
- public static IEnumerable ResolveAll(this IDependencyResolver resolver)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- return resolver.GetServices(typeof(T)).Cast();
- }
-
- public static IEnumerable ResolveAll(this IDependencyResolver resolver, Type type)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- if (type == null)
- {
- throw new ArgumentNullException("type");
- }
-
- return resolver.GetServices(type);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/GlobalHost.cs b/src/Microsoft.AspNet.SignalR.Core/GlobalHost.cs
deleted file mode 100644
index 7571495fc..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/GlobalHost.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using Microsoft.AspNet.SignalR.Configuration;
-using Microsoft.AspNet.SignalR.Hubs;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR
-{
- ///
- /// Provides access to default host information.
- ///
- public static class GlobalHost
- {
- private static readonly Lazy _defaultResolver = new Lazy(() => new DefaultDependencyResolver());
- private static IDependencyResolver _resolver;
-
- ///
- /// Gets or sets the the default
- ///
- public static IDependencyResolver DependencyResolver
- {
- get
- {
- return _resolver ?? _defaultResolver.Value;
- }
- set
- {
- _resolver = value;
- }
- }
-
- ///
- /// Gets the default
- ///
- public static IConfigurationManager Configuration
- {
- get
- {
- return DependencyResolver.Resolve();
- }
- }
-
- ///
- /// Gets the default
- ///
- public static IConnectionManager ConnectionManager
- {
- get
- {
- return DependencyResolver.Resolve();
- }
- }
-
- ///
- ///
- ///
- public static IHubPipeline HubPipeline
- {
- get
- {
- return DependencyResolver.Resolve();
- }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/GroupManager.cs b/src/Microsoft.AspNet.SignalR.Core/GroupManager.cs
deleted file mode 100644
index c57476f70..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/GroupManager.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-using Microsoft.AspNet.SignalR.Messaging;
-
-namespace Microsoft.AspNet.SignalR
-{
- ///
- /// The default implementation.
- ///
- public class GroupManager : IConnectionGroupManager
- {
- private readonly IConnection _connection;
- private readonly string _groupPrefix;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The this group resides on.
- /// The prefix for this group. Either a name or type name.
- public GroupManager(IConnection connection, string groupPrefix)
- {
- if (connection == null)
- {
- throw new ArgumentNullException("connection");
- }
-
- _connection = connection;
- _groupPrefix = groupPrefix;
- }
-
- ///
- /// Sends a value to the specified group.
- ///
- /// The name of the group.
- /// The value to send.
- /// The list of connection ids to exclude
- /// A task that represents when send is complete.
- public Task Send(string groupName, object value, params string[] excludeConnectionIds)
- {
- if (string.IsNullOrEmpty(groupName))
- {
- throw new ArgumentException((Resources.Error_ArgumentNullOrEmpty), "groupName");
- }
-
- var qualifiedName = CreateQualifiedName(groupName);
- var message = new ConnectionMessage(qualifiedName,
- value,
- PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));
-
- return _connection.Send(message);
- }
-
- ///
- /// Adds a connection to the specified group.
- ///
- /// The connection id to add to the group.
- /// The name of the group
- /// A task that represents the connection id being added to the group.
- public Task Add(string connectionId, string groupName)
- {
- if (connectionId == null)
- {
- throw new ArgumentNullException("connectionId");
- }
-
- if (groupName == null)
- {
- throw new ArgumentNullException("groupName");
- }
-
- var command = new Command
- {
- CommandType = CommandType.AddToGroup,
- Value = CreateQualifiedName(groupName),
- WaitForAck = true
- };
-
- return _connection.Send(connectionId, command);
- }
-
- ///
- /// Removes a connection from the specified group.
- ///
- /// The connection id to remove from the group.
- /// The name of the group
- /// A task that represents the connection id being removed from the group.
- public Task Remove(string connectionId, string groupName)
- {
- if (connectionId == null)
- {
- throw new ArgumentNullException("connectionId");
- }
-
- if (groupName == null)
- {
- throw new ArgumentNullException("groupName");
- }
-
- var command = new Command
- {
- CommandType = CommandType.RemoveFromGroup,
- Value = CreateQualifiedName(groupName),
- WaitForAck = true
- };
-
- return _connection.Send(connectionId, command);
- }
-
- private string CreateQualifiedName(string groupName)
- {
- return _groupPrefix + "." + groupName;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostConstants.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/HostConstants.cs
deleted file mode 100644
index 9cb8b132a..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostConstants.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- public static class HostConstants
- {
- ///
- /// The host should set this if they need to enable debug mode
- ///
- public static readonly string DebugMode = "debugMode";
-
- ///
- /// The host should set this is web sockets can be supported
- ///
- public static readonly string SupportsWebSockets = "supportsWebSockets";
-
- ///
- /// The host should set this if the web socket url is different
- ///
- public static readonly string WebSocketServerUrl = "webSocketServerUrl";
-
- public static readonly string ShutdownToken = "shutdownToken";
-
- public static readonly string InstanceName = "instanceName";
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContext.cs
deleted file mode 100644
index cd5324f90..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContext.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- public class HostContext
- {
- public IRequest Request { get; private set; }
- public IResponse Response { get; private set; }
- public IDictionary Items { get; private set; }
-
- public HostContext(IRequest request, IResponse response)
- {
- Request = request;
- Response = response;
- Items = new Dictionary(StringComparer.OrdinalIgnoreCase);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContextExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContextExtensions.cs
deleted file mode 100644
index d40d9e5ac..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostContextExtensions.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- public static class HostContextExtensions
- {
- public static T GetValue(this HostContext context, string key)
- {
- if (context == null)
- {
- throw new ArgumentNullException("context");
- }
-
- object value;
- if (context.Items.TryGetValue(key, out value))
- {
- return (T)value;
- }
- return default(T);
- }
-
- public static bool IsDebuggingEnabled(this HostContext context)
- {
- return context.GetValue(HostConstants.DebugMode);
- }
-
- public static bool SupportsWebSockets(this HostContext context)
- {
- // The server needs to implement IWebSocketRequest for websockets to be supported.
- // It also needs to set the flag in the items collection.
- return context.GetValue(HostConstants.SupportsWebSockets) &&
- context.Request is IWebSocketRequest;
- }
-
- public static string WebSocketServerUrl(this HostContext context)
- {
- return context.GetValue(HostConstants.WebSocketServerUrl);
- }
-
- public static CancellationToken HostShutdownToken(this HostContext context)
- {
- return context.GetValue(HostConstants.ShutdownToken);
- }
-
- public static string InstanceName(this HostContext context)
- {
- return context.GetValue(HostConstants.InstanceName);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostDependencyResolverExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/HostDependencyResolverExtensions.cs
deleted file mode 100644
index c674b317b..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/HostDependencyResolverExtensions.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- public static class HostDependencyResolverExtensions
- {
- public static void InitializeHost(this IDependencyResolver resolver, string instanceName, CancellationToken hostShutdownToken)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- if (String.IsNullOrEmpty(instanceName))
- {
- throw new ArgumentNullException("instanceName");
- }
-
- // Performance counters are broken on mono so just skip this step
- if (!MonoUtility.IsRunningMono)
- {
- // Initialize the performance counters
- resolver.InitializePerformanceCounters(instanceName, hostShutdownToken);
- }
-
- // Dispose the dependency resolver on host shut down (cleanly)
- resolver.InitializeResolverDispose(hostShutdownToken);
- }
-
- private static void InitializePerformanceCounters(this IDependencyResolver resolver, string instanceName, CancellationToken hostShutdownToken)
- {
- var counters = resolver.Resolve();
- if (counters != null)
- {
- counters.Initialize(instanceName, hostShutdownToken);
- }
- }
-
- private static void InitializeResolverDispose(this IDependencyResolver resolver, CancellationToken hostShutdownToken)
- {
- // TODO: Guard against multiple calls to this
-
- // When the host triggers the shutdown token, dispose the resolver
- hostShutdownToken.SafeRegister(state =>
- {
- ((IDependencyResolver)state).Dispose();
- },
- resolver);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/IResponse.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/IResponse.cs
deleted file mode 100644
index 3d26f0e61..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/IResponse.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- ///
- /// Represents a connection to the client.
- ///
- public interface IResponse
- {
- ///
- /// Gets a cancellation token that represents the client's lifetime.
- ///
- CancellationToken CancellationToken { get; }
-
- ///
- /// Gets or sets the status code of the response.
- ///
- int StatusCode { get; set; }
-
- ///
- /// Gets or sets the content type of the response.
- ///
- string ContentType { get; set; }
-
- ///
- /// Writes buffered data.
- ///
- /// The data to write to the buffer.
- void Write(ArraySegment data);
-
- ///
- /// Flushes the buffered response to the client.
- ///
- /// A task that represents when the data has been flushed.
- Task Flush();
-
- ///
- /// Closes the connection to the client.
- ///
- /// A task that represents when the connection is closed.
- [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "End", Justification = "Ends the response thus the name is appropriate.")]
- Task End();
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocket.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocket.cs
deleted file mode 100644
index 60c448f2a..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocket.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- ///
- /// Represents a web socket.
- ///
- public interface IWebSocket
- {
- ///
- /// Invoked when data is sent over the websocket
- ///
- Action OnMessage { get; set; }
-
- ///
- /// Invoked when the websocket closes
- ///
- Action OnClose { get; set; }
-
- ///
- /// Invoked when there is an error
- ///
- Action OnError { get; set; }
-
- ///
- /// Sends data over the websocket.
- ///
- /// The value to send.
- /// A that represents the send is complete.
- Task Send(string value);
-
- ///
- /// Sends a chunk of data over the websocket ("endOfMessage" flag set to false.)
- ///
- ///
- /// A that represents the send is complete.
- Task SendChunk(ArraySegment message);
-
- ///
- /// Sends a zero byte data chunk with the "endOfMessage" flag set to true.
- ///
- /// A that represents the flush is complete.
- Task Flush();
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocketRequest.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocketRequest.cs
deleted file mode 100644
index 95f5438f2..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/IWebSocketRequest.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- public interface IWebSocketRequest : IRequest
- {
- ///
- /// Accepts an websocket request using the specified user function.
- ///
- /// The callback that fires when the websocket is ready.
- /// The task that completes when the websocket transport is ready.
- Task AcceptWebSocketRequest(Func callback, Task initTask);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/PersistentConnectionFactory.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/PersistentConnectionFactory.cs
deleted file mode 100644
index 33d9aeee1..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/PersistentConnectionFactory.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Globalization;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- ///
- /// Responsible for creating instances.
- ///
- public class PersistentConnectionFactory
- {
- private readonly IDependencyResolver _resolver;
-
- ///
- /// Creates a new instance of the class.
- ///
- /// The dependency resolver to use for when creating the .
- public PersistentConnectionFactory(IDependencyResolver resolver)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- _resolver = resolver;
- }
-
- ///
- /// Creates an instance of the specified type using the dependency resolver or the type's default constructor.
- ///
- /// The type of to create.
- /// An instance of a .
- public PersistentConnection CreateInstance(Type connectionType)
- {
- if (connectionType == null)
- {
- throw new ArgumentNullException("connectionType");
- }
-
- var connection = (_resolver.Resolve(connectionType) ??
- Activator.CreateInstance(connectionType)) as PersistentConnection;
-
- if (connection == null)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_IsNotA, connectionType.FullName, typeof(PersistentConnection).FullName));
- }
-
- return connection;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/RequestExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/RequestExtensions.cs
deleted file mode 100644
index 52cba0096..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/RequestExtensions.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- internal static class RequestExtensions
- {
- ///
- /// Gets a value from the QueryString, and if it's null or empty, gets it from the Form instead.
- ///
- public static string QueryStringOrForm(this IRequest request, string key)
- {
- var value = request.QueryString[key];
- if (String.IsNullOrEmpty(value))
- {
- value = request.Form[key];
- }
- return value;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hosting/ResponseExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hosting/ResponseExtensions.cs
deleted file mode 100644
index a8f79a922..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hosting/ResponseExtensions.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hosting
-{
- ///
- /// Extension methods for .
- ///
- public static class ResponseExtensions
- {
- ///
- /// Closes the connection to a client with optional data.
- ///
- /// The .
- /// The data to write to the connection.
- /// A task that represents when the connection is closed.
- public static Task End(this IResponse response, string data)
- {
- if (response == null)
- {
- throw new ArgumentNullException("response");
- }
-
- var bytes = Encoding.UTF8.GetBytes(data);
- response.Write(new ArraySegment(bytes, 0, bytes.Length));
- return response.End();
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hub.cs b/src/Microsoft.AspNet.SignalR.Core/Hub.cs
deleted file mode 100644
index ca86f39e9..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hub.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Hubs;
-
-namespace Microsoft.AspNet.SignalR
-{
- ///
- /// Provides methods that communicate with SignalR connections that connected to a .
- ///
- public abstract class Hub : IHub
- {
- protected Hub()
- {
- Clients = new HubConnectionContext();
- Clients.All = new NullClientProxy();
- Clients.Others = new NullClientProxy();
- Clients.Caller = new NullClientProxy();
- }
-
- ///
- ///
- ///
- public HubConnectionContext Clients { get; set; }
-
- ///
- /// Provides information about the calling client.
- ///
- public HubCallerContext Context { get; set; }
-
- ///
- /// The group manager for this hub instance.
- ///
- public IGroupManager Groups { get; set; }
-
- ///
- /// Called when a connection disconnects from this hub instance.
- ///
- /// A
- public virtual Task OnDisconnected()
- {
- return TaskAsyncHelper.Empty;
- }
-
- ///
- /// Called when the connection connects to this hub instance.
- ///
- /// A
- public virtual Task OnConnected()
- {
- return TaskAsyncHelper.Empty;
- }
-
- ///
- /// Called when the connection reconnects to this hub instance.
- ///
- /// A
- public virtual Task OnReconnected()
- {
- return TaskAsyncHelper.Empty;
- }
-
- protected virtual void Dispose(bool disposing)
- {
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/HubConfiguration.cs b/src/Microsoft.AspNet.SignalR.Core/HubConfiguration.cs
deleted file mode 100644
index 13abdc5bc..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/HubConfiguration.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR
-{
- public class HubConfiguration : ConnectionConfiguration
- {
- ///
- /// Determines whether JavaScript proxies for the server-side hubs should be auto generated at {Path}/hubs.
- /// Defaults to true.
- ///
- public bool EnableJavaScriptProxies { get; set; }
-
- ///
- /// Determines whether detailed exceptions thrown in Hub methods get reported back the invoking client.
- /// Defaults to false.
- ///
- public bool EnableDetailedErrors { get; set; }
-
- public HubConfiguration()
- {
- EnableJavaScriptProxies = true;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientHubInvocation.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientHubInvocation.cs
deleted file mode 100644
index 37dd52233..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientHubInvocation.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Newtonsoft.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// A description of a client-side hub method invocation.
- ///
- public class ClientHubInvocation
- {
- ///
- /// The signal that clients receiving this invocation are subscribed to.
- ///
- [JsonIgnore]
- public string Target { get; set; }
-
- ///
- /// The name of the hub that the method being invoked belongs to.
- ///
- [JsonProperty("H")]
- public string Hub { get; set; }
-
- ///
- /// The name of the client-side hub method be invoked.
- ///
- [JsonProperty("M")]
- public string Method { get; set; }
-
- ///
- /// The argument list the client-side hub method will be called with.
- ///
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Type is used for serialization.")]
- [JsonProperty("A")]
- public object[] Args { get; set; }
-
- ///
- /// A key-value store representing the hub state on the server that has changed since the last time the hub
- /// state was sent to the client.
- ///
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Type is used for serialization.")]
- [JsonProperty("S", NullValueHandling = NullValueHandling.Ignore)]
- public IDictionary State { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientProxy.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientProxy.cs
deleted file mode 100644
index df87a13f1..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/ClientProxy.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Dynamic;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class ClientProxy : DynamicObject, IClientProxy
- {
- private readonly Func, Task> _send;
- private readonly string _hubName;
- private readonly IList _exclude;
-
- public ClientProxy(Func, Task> send, string hubName, IList exclude)
- {
- _send = send;
- _hubName = hubName;
- _exclude = exclude;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Binder is passed in by the DLR")]
- public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
- {
- result = Invoke(binder.Name, args);
- return true;
- }
-
- public Task Invoke(string method, params object[] args)
- {
- var invocation = new ClientHubInvocation
- {
- Hub = _hubName,
- Method = method,
- Args = args
- };
-
- return _send(PrefixHelper.GetHubName(_hubName), invocation, _exclude);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/ConnectionIdProxy.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/ConnectionIdProxy.cs
deleted file mode 100644
index cf3520fb8..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/ConnectionIdProxy.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class ConnectionIdProxy : SignalProxy
- {
- public ConnectionIdProxy(Func, Task> send, string signal, string hubName, params string[] exclude) :
- base(send, signal, hubName, PrefixHelper.HubConnectionIdPrefix, exclude)
- {
-
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultAssemblyLocator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultAssemblyLocator.cs
deleted file mode 100644
index b25b1985d..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultAssemblyLocator.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DefaultAssemblyLocator : IAssemblyLocator
- {
- public virtual IList GetAssemblies()
- {
- return AppDomain.CurrentDomain.GetAssemblies();
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultHubActivator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultHubActivator.cs
deleted file mode 100644
index 8f160d09a..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultHubActivator.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DefaultHubActivator : IHubActivator
- {
- private readonly IDependencyResolver _resolver;
-
- public DefaultHubActivator(IDependencyResolver resolver)
- {
- _resolver = resolver;
- }
-
- public IHub Create(HubDescriptor descriptor)
- {
- if (descriptor == null)
- {
- throw new ArgumentNullException("descriptor");
- }
-
- if(descriptor.HubType == null)
- {
- return null;
- }
-
- object hub = _resolver.Resolve(descriptor.HubType) ?? Activator.CreateInstance(descriptor.HubType);
- return hub as IHub;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultJavaScriptProxyGenerator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultJavaScriptProxyGenerator.cs
deleted file mode 100644
index 7e84b318e..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/DefaultJavaScriptProxyGenerator.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Globalization;
-using System.IO;
-using System.Linq;
-using System.Text;
-using Microsoft.AspNet.SignalR.Json;
-using Newtonsoft.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DefaultJavaScriptProxyGenerator : IJavaScriptProxyGenerator
- {
- private static readonly Lazy _templateFromResource = new Lazy(GetTemplateFromResource);
-
- private static readonly Type[] _numberTypes = new[] { typeof(byte), typeof(short), typeof(int), typeof(long), typeof(float), typeof(decimal), typeof(double) };
- private static readonly Type[] _dateTypes = new[] { typeof(DateTime), typeof(DateTimeOffset) };
-
- private const string ScriptResource = "Microsoft.AspNet.SignalR.Scripts.hubs.js";
-
- private readonly IHubManager _manager;
- private readonly IJavaScriptMinifier _javaScriptMinifier;
- private readonly Lazy _generatedTemplate;
-
- public DefaultJavaScriptProxyGenerator(IDependencyResolver resolver) :
- this(resolver.Resolve(),
- resolver.Resolve())
- {
- }
-
- public DefaultJavaScriptProxyGenerator(IHubManager manager, IJavaScriptMinifier javaScriptMinifier)
- {
- _manager = manager;
- _javaScriptMinifier = javaScriptMinifier ?? NullJavaScriptMinifier.Instance;
- _generatedTemplate = new Lazy(() => GenerateProxy(_manager, _javaScriptMinifier, includeDocComments: false));
- }
-
- public string GenerateProxy(string serviceUrl)
- {
- serviceUrl = JavaScriptEncode(serviceUrl);
-
- var generateProxy = _generatedTemplate.Value;
-
- return generateProxy.Replace("{serviceUrl}", serviceUrl);
- }
-
- public string GenerateProxy(string serviceUrl, bool includeDocComments)
- {
- serviceUrl = JavaScriptEncode(serviceUrl);
-
- string generateProxy = GenerateProxy(_manager, _javaScriptMinifier, includeDocComments);
-
- return generateProxy.Replace("{serviceUrl}", serviceUrl);
- }
-
- private static string GenerateProxy(IHubManager hubManager, IJavaScriptMinifier javaScriptMinifier, bool includeDocComments)
- {
- string script = _templateFromResource.Value;
-
- var hubs = new StringBuilder();
- var first = true;
- foreach (var descriptor in hubManager.GetHubs().OrderBy(h => h.Name))
- {
- if (!first)
- {
- hubs.AppendLine(";");
- hubs.AppendLine();
- hubs.Append(" ");
- }
- GenerateType(hubManager, hubs, descriptor, includeDocComments);
- first = false;
- }
-
- if (hubs.Length > 0)
- {
- hubs.Append(";");
- }
-
- script = script.Replace("/*hubs*/", hubs.ToString());
-
- return javaScriptMinifier.Minify(script);
- }
-
- private static void GenerateType(IHubManager hubManager, StringBuilder sb, HubDescriptor descriptor, bool includeDocComments)
- {
- // Get only actions with minimum number of parameters.
- var methods = GetMethods(hubManager, descriptor);
- var hubName = GetDescriptorName(descriptor);
-
- sb.AppendFormat(" proxies.{0} = this.createHubProxy('{1}'); ", hubName, hubName).AppendLine();
- sb.AppendFormat(" proxies.{0}.client = {{ }};", hubName).AppendLine();
- sb.AppendFormat(" proxies.{0}.server = {{", hubName);
-
- bool first = true;
-
- foreach (var method in methods)
- {
- if (!first)
- {
- sb.Append(",").AppendLine();
- }
- GenerateMethod(sb, method, includeDocComments, hubName);
- first = false;
- }
- sb.AppendLine();
- sb.Append(" }");
- }
-
- private static string GetDescriptorName(Descriptor descriptor)
- {
- if (descriptor == null)
- {
- throw new ArgumentNullException("descriptor");
- }
-
- string name = descriptor.Name;
-
- // If the name was not specified then do not camel case
- if (!descriptor.NameSpecified)
- {
- name = JsonUtility.CamelCase(name);
- }
-
- return name;
- }
-
- private static IEnumerable GetMethods(IHubManager manager, HubDescriptor descriptor)
- {
- return from method in manager.GetHubMethods(descriptor.Name)
- group method by method.Name into overloads
- let oload = (from overload in overloads
- orderby overload.Parameters.Count
- select overload).FirstOrDefault()
- orderby oload.Name
- select oload;
- }
-
- private static void GenerateMethod(StringBuilder sb, MethodDescriptor method, bool includeDocComments, string hubName)
- {
- var parameterNames = method.Parameters.Select(p => p.Name).ToList();
- sb.AppendLine();
- sb.AppendFormat(" {0}: function ({1}) {{", GetDescriptorName(method), Commas(parameterNames)).AppendLine();
- if (includeDocComments)
- {
- sb.AppendFormat(Resources.DynamicComment_CallsMethodOnServerSideDeferredPromise, method.Name, method.Hub.Name).AppendLine();
- var parameterDoc = method.Parameters.Select(p => String.Format(CultureInfo.CurrentCulture, Resources.DynamicComment_ServerSideTypeIs, p.Name, MapToJavaScriptType(p.ParameterType), p.ParameterType)).ToList();
- if (parameterDoc.Any())
- {
- sb.AppendLine(String.Join(Environment.NewLine, parameterDoc));
- }
- }
- sb.AppendFormat(" return proxies.{0}.invoke.apply(proxies.{0}, $.merge([\"{1}\"], $.makeArray(arguments)));", hubName, method.Name).AppendLine();
- sb.Append(" }");
- }
-
- private static string MapToJavaScriptType(Type type)
- {
- if (!type.IsPrimitive && !(type == typeof(string)))
- {
- return "Object";
- }
- if (type == typeof(string))
- {
- return "String";
- }
- if (_numberTypes.Contains(type))
- {
- return "Number";
- }
- if (typeof(IEnumerable).IsAssignableFrom(type))
- {
- return "Array";
- }
- if (_dateTypes.Contains(type))
- {
- return "Date";
- }
- return String.Empty;
- }
-
- private static string Commas(IEnumerable values)
- {
- return Commas(values, v => v);
- }
-
- private static string Commas(IEnumerable values, Func selector)
- {
- return String.Join(", ", values.Select(selector));
- }
-
- private static string GetTemplateFromResource()
- {
- using (Stream resourceStream = typeof(DefaultJavaScriptProxyGenerator).Assembly.GetManifestResourceStream(ScriptResource))
- {
- var reader = new StreamReader(resourceStream);
- return reader.ReadToEnd();
- }
- }
-
- private static string JavaScriptEncode(string value)
- {
- value = JsonConvert.SerializeObject(value);
-
- // Remove the quotes
- return value.Substring(1, value.Length - 2);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/DynamicDictionary.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/DynamicDictionary.cs
deleted file mode 100644
index 0a9963108..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/DynamicDictionary.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Dynamic;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DynamicDictionary : DynamicObject, IDictionary
- {
- private readonly IDictionary _obj;
-
- public DynamicDictionary(IDictionary obj)
- {
- _obj = obj;
- }
-
- public object this[string key]
- {
- get
- {
- object result;
- _obj.TryGetValue(key, out result);
- return Wrap(result);
- }
- set
- {
- _obj[key] = Unwrap(value);
- }
- }
-
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "The compiler generates calls to invoke this")]
- public override bool TryGetMember(GetMemberBinder binder, out object result)
- {
- result = this[binder.Name];
- return true;
- }
-
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "The compiler generates calls to invoke this")]
- public override bool TrySetMember(SetMemberBinder binder, object value)
- {
- this[binder.Name] = value;
- return true;
- }
-
- public static object Wrap(object value)
- {
- var obj = value as IDictionary;
- if (obj != null)
- {
- return new DynamicDictionary(obj);
- }
-
- return value;
- }
-
- public static object Unwrap(object value)
- {
- var dictWrapper = value as DynamicDictionary;
- if (dictWrapper != null)
- {
- return dictWrapper._obj;
- }
-
- return value;
- }
-
- public void Add(string key, object value)
- {
- _obj.Add(key, value);
- }
-
- public bool ContainsKey(string key)
- {
- return _obj.ContainsKey(key);
- }
-
- public ICollection Keys
- {
- get { return _obj.Keys; }
- }
-
- public bool Remove(string key)
- {
- return _obj.Remove(key);
- }
-
- public bool TryGetValue(string key, out object value)
- {
- return _obj.TryGetValue(key, out value);
- }
-
- public ICollection Values
- {
- get { return _obj.Values; }
- }
-
- public void Add(KeyValuePair item)
- {
- _obj.Add(item);
- }
-
- public void Clear()
- {
- _obj.Clear();
- }
-
- public bool Contains(KeyValuePair item)
- {
- return _obj.Contains(item);
- }
-
- public void CopyTo(KeyValuePair[] array, int arrayIndex)
- {
- _obj.CopyTo(array, arrayIndex);
- }
-
- public int Count
- {
- get { return _obj.Count; }
- }
-
- public bool IsReadOnly
- {
- get { return _obj.IsReadOnly; }
- }
-
- public bool Remove(KeyValuePair item)
- {
- return _obj.Remove(item);
- }
-
- public IEnumerator> GetEnumerator()
- {
- return _obj.GetEnumerator();
- }
-
- IEnumerator IEnumerable.GetEnumerator()
- {
- return GetEnumerator();
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/EmptyJavaScriptProxyGenerator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/EmptyJavaScriptProxyGenerator.cs
deleted file mode 100644
index d0ed9055e..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/EmptyJavaScriptProxyGenerator.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Globalization;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class EmptyJavaScriptProxyGenerator : IJavaScriptProxyGenerator
- {
- public string GenerateProxy(string serviceUrl)
- {
- return String.Format(CultureInfo.InvariantCulture, "throw new Error('{0}');", Resources.Error_JavaScriptProxyDisabled);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubManagerExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubManagerExtensions.cs
deleted file mode 100644
index bc5455b59..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubManagerExtensions.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public static class HubManagerExtensions
- {
- public static HubDescriptor EnsureHub(this IHubManager hubManager, string hubName, params IPerformanceCounter[] counters)
- {
- if (hubManager == null)
- {
- throw new ArgumentNullException("hubManager");
- }
-
- if (String.IsNullOrEmpty(hubName))
- {
- throw new ArgumentNullException("hubName");
- }
-
- if (counters == null)
- {
- throw new ArgumentNullException("counters");
- }
-
- var descriptor = hubManager.GetHub(hubName);
-
- if (descriptor == null)
- {
- for (var i = 0; i < counters.Length; i++)
- {
- counters[i].Increment();
- }
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_HubCouldNotBeResolved, hubName));
- }
-
- return descriptor;
- }
-
- public static IEnumerable GetHubs(this IHubManager hubManager)
- {
- if (hubManager == null)
- {
- throw new ArgumentNullException("hubManager");
- }
-
- return hubManager.GetHubs(d => true);
- }
-
- public static IEnumerable GetHubMethods(this IHubManager hubManager, string hubName)
- {
- if (hubManager == null)
- {
- throw new ArgumentNullException("hubManager");
- }
-
- return hubManager.GetHubMethods(hubName, m => true);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubTypeExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubTypeExtensions.cs
deleted file mode 100644
index 1bf73da42..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/HubTypeExtensions.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal static class HubTypeExtensions
- {
- internal static string GetHubName(this Type type)
- {
- if (!typeof(IHub).IsAssignableFrom(type))
- {
- return null;
- }
-
- return GetHubAttributeName(type) ?? type.Name;
- }
-
- internal static string GetHubAttributeName(this Type type)
- {
- if (!typeof(IHub).IsAssignableFrom(type))
- {
- return null;
- }
-
- // We can still return null if there is no attribute name
- return ReflectionHelper.GetAttributeValue(type, attr => attr.HubName);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/MethodExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/MethodExtensions.cs
deleted file mode 100644
index 3418e8566..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Extensions/MethodExtensions.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public static class MethodExtensions
- {
- [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Justification = "The condition checks for null parameters")]
- public static bool Matches(this MethodDescriptor methodDescriptor, IList parameters)
- {
- if (methodDescriptor == null)
- {
- throw new ArgumentNullException("methodDescriptor");
- }
-
- if ((methodDescriptor.Parameters.Count > 0 && parameters == null)
- || methodDescriptor.Parameters.Count != parameters.Count)
- {
- return false;
- }
-
- return true;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/GroupProxy.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/GroupProxy.cs
deleted file mode 100644
index 9ca86d5ce..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/GroupProxy.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class GroupProxy : SignalProxy
- {
- public GroupProxy(Func, Task> send, string signal, string hubName, IList exclude) :
- base(send, signal, hubName, PrefixHelper.HubGroupPrefix, exclude)
- {
-
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubCallerContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubCallerContext.cs
deleted file mode 100644
index 2413da7da..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubCallerContext.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Security.Principal;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class HubCallerContext
- {
- ///
- /// Gets the connection id of the calling client.
- ///
- public string ConnectionId { get; private set; }
-
- ///
- /// Gets the cookies for the request.
- ///
- public IDictionary RequestCookies
- {
- get
- {
- return Request.Cookies;
- }
- }
-
- ///
- /// Gets the headers for the request.
- ///
- public NameValueCollection Headers
- {
- get
- {
- return Request.Headers;
- }
- }
-
- ///
- /// Gets the querystring for the request.
- ///
- public NameValueCollection QueryString
- {
- get
- {
- return Request.QueryString;
- }
- }
-
- ///
- /// Gets the for the request.
- ///
- public IPrincipal User
- {
- get
- {
- return Request.User;
- }
- }
-
- ///
- /// Gets the for the current HTTP request.
- ///
- public IRequest Request { get; private set; }
-
- public HubCallerContext(IRequest request, string connectionId)
- {
- ConnectionId = connectionId;
- Request = request;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubConnectionContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubConnectionContext.cs
deleted file mode 100644
index fded4874b..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubConnectionContext.cs
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Encapsulates all information about an individual SignalR connection for an .
- ///
- public class HubConnectionContext : IHubConnectionContext
- {
- private readonly string _hubName;
- private readonly string _connectionId;
- private readonly Func, Task> _send;
-
- ///
- /// Initializes a new instance of the .
- ///
- public HubConnectionContext()
- {
- }
-
- ///
- /// Initializes a new instance of the .
- ///
- /// The pipeline invoker.
- /// The connection.
- /// The hub name.
- /// The connection id.
- /// The connection hub state.
- public HubConnectionContext(IHubPipelineInvoker pipelineInvoker, IConnection connection, string hubName, string connectionId, StateChangeTracker tracker)
- {
- _send = (signal, invocation, exclude) => pipelineInvoker.Send(new HubOutgoingInvokerContext(connection, signal, invocation, exclude));
- _connectionId = connectionId;
- _hubName = hubName;
-
- Caller = new StatefulSignalProxy(_send, connectionId, PrefixHelper.HubConnectionIdPrefix, hubName, tracker);
- All = AllExcept();
- Others = AllExcept(connectionId);
- }
-
- ///
- /// All connected clients.
- ///
- public dynamic All { get; set; }
-
- ///
- /// All connected clients except the calling client.
- ///
- public dynamic Others { get; set; }
-
- ///
- /// Represents the calling client.
- ///
- public dynamic Caller { get; set; }
-
- ///
- /// Returns a dynamic representation of all clients except the calling client ones specified.
- ///
- /// The list of connection ids to exclude
- /// A dynamic representation of all clients except the calling client ones specified.
- public dynamic AllExcept(params string[] excludeConnectionIds)
- {
- return new ClientProxy(_send, _hubName, PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));
- }
-
- ///
- /// Returns a dynamic representation of all clients in a group except the calling client.
- ///
- /// The name of the group
- /// A dynamic representation of all clients in a group except the calling client.
- public dynamic OthersInGroup(string groupName)
- {
- return Group(groupName, _connectionId);
- }
-
- ///
- /// Returns a dynamic representation of the specified group.
- ///
- /// The name of the group
- /// The list of connection ids to exclude
- /// A dynamic representation of the specified group.
- public dynamic Group(string groupName, params string[] excludeConnectionIds)
- {
- if (string.IsNullOrEmpty(groupName))
- {
- throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "groupName");
- }
-
- return new GroupProxy(_send, groupName, _hubName, PrefixHelper.GetPrefixedConnectionIds(excludeConnectionIds));
- }
-
- ///
- /// Returns a dynamic representation of the connection with the specified connectionid.
- ///
- /// The connection id
- /// A dynamic representation of the specified client.
- public dynamic Client(string connectionId)
- {
- if (string.IsNullOrEmpty(connectionId))
- {
- throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
- }
-
- return new ConnectionIdProxy(_send, connectionId, _hubName);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubContext.cs
deleted file mode 100644
index 37a295dcf..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubContext.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Infrastructure;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubContext : IHubContext
- {
- public HubContext(Func, Task> send, string hubName, IConnection connection)
- {
- Clients = new ExternalHubConnectionContext(send, hubName);
- Groups = new GroupManager(connection, PrefixHelper.GetHubGroupName(hubName));
- }
-
- public IHubConnectionContext Clients { get; private set; }
-
- public IGroupManager Groups { get; private set; }
-
- private class ExternalHubConnectionContext : IHubConnectionContext
- {
- private readonly Func, Task> _send;
- private readonly string _hubName;
-
- public ExternalHubConnectionContext(Func, Task> send, string hubName)
- {
- _send = send;
- _hubName = hubName;
- All = AllExcept();
- }
-
- public dynamic All
- {
- get;
- private set;
- }
-
- public dynamic AllExcept(params string[] exclude)
- {
- return new ClientProxy(_send, _hubName, exclude);
- }
-
- public dynamic Group(string groupName, params string[] exclude)
- {
- if (string.IsNullOrEmpty(groupName))
- {
- throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "groupName");
- }
-
- return new GroupProxy(_send, groupName, _hubName, exclude);
- }
-
- public dynamic Client(string connectionId)
- {
- if (string.IsNullOrEmpty(connectionId))
- {
- throw new ArgumentException(Resources.Error_ArgumentNullOrEmpty, "connectionId");
- }
-
- return new ConnectionIdProxy(_send, connectionId, _hubName);
- }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubDispatcher.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubDispatcher.cs
deleted file mode 100644
index b97aa74c5..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubDispatcher.cs
+++ /dev/null
@@ -1,522 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Diagnostics.CodeAnalysis;
-using System.Globalization;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
-using System.Threading.Tasks;
-using Microsoft.AspNet.SignalR.Hosting;
-using Microsoft.AspNet.SignalR.Infrastructure;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Handles all communication over the hubs persistent connection.
- ///
- [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Justification = "This dispatcher makes use of many interfaces.")]
- public class HubDispatcher : PersistentConnection
- {
- private const string HubsSuffix = "/hubs";
-
- private readonly List _hubs = new List();
- private readonly bool _enableJavaScriptProxies;
- private readonly bool _enableDetailedErrors;
-
- private IJavaScriptProxyGenerator _proxyGenerator;
- private IHubManager _manager;
- private IHubRequestParser _requestParser;
- private IParameterResolver _binder;
- private IHubPipelineInvoker _pipelineInvoker;
- private IPerformanceCounterManager _counters;
- private bool _isDebuggingEnabled;
-
- private static readonly MethodInfo _continueWithMethod = typeof(HubDispatcher).GetMethod("ContinueWith", BindingFlags.NonPublic | BindingFlags.Static);
-
- ///
- /// Initializes an instance of the class.
- ///
- /// Configuration settings determining whether to enable JS proxies and provide clients with detailed hub errors.
- public HubDispatcher(HubConfiguration configuration)
- {
- if (configuration == null)
- {
- throw new ArgumentNullException("configuration");
- }
-
- _enableJavaScriptProxies = configuration.EnableJavaScriptProxies;
- _enableDetailedErrors = configuration.EnableDetailedErrors;
- }
-
- protected override TraceSource Trace
- {
- get
- {
- return TraceManager["SignalR.HubDispatcher"];
- }
- }
-
- internal override string GroupPrefix
- {
- get
- {
- return PrefixHelper.HubGroupPrefix;
- }
- }
-
- public override void Initialize(IDependencyResolver resolver, HostContext context)
- {
- if (resolver == null)
- {
- throw new ArgumentNullException("resolver");
- }
-
- if (context == null)
- {
- throw new ArgumentNullException("context");
- }
-
- _proxyGenerator = _enableJavaScriptProxies ? resolver.Resolve()
- : new EmptyJavaScriptProxyGenerator();
-
- _manager = resolver.Resolve();
- _binder = resolver.Resolve();
- _requestParser = resolver.Resolve();
- _pipelineInvoker = resolver.Resolve();
- _counters = resolver.Resolve();
-
- base.Initialize(resolver, context);
- }
-
- protected override bool AuthorizeRequest(IRequest request)
- {
- // Populate _hubs
- string data = request.QueryStringOrForm("connectionData");
-
- if (!String.IsNullOrEmpty(data))
- {
- var clientHubInfo = JsonSerializer.Parse>(data);
-
- // If there's any hubs then perform the auth check
- if (clientHubInfo != null && clientHubInfo.Any())
- {
- var hubCache = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- foreach (var hubInfo in clientHubInfo)
- {
- if (hubCache.ContainsKey(hubInfo.Name))
- {
- throw new InvalidOperationException(Resources.Error_DuplicateHubs);
- }
-
- // Try to find the associated hub type
- HubDescriptor hubDescriptor = _manager.EnsureHub(hubInfo.Name,
- _counters.ErrorsHubResolutionTotal,
- _counters.ErrorsHubResolutionPerSec,
- _counters.ErrorsAllTotal,
- _counters.ErrorsAllPerSec);
-
- if (_pipelineInvoker.AuthorizeConnect(hubDescriptor, request))
- {
- // Add this to the list of hub descriptors this connection is interested in
- hubCache.Add(hubDescriptor.Name, hubDescriptor);
- }
- }
-
- _hubs.AddRange(hubCache.Values);
-
- // If we have any hubs in the list then we're authorized
- return _hubs.Count > 0;
- }
- }
-
- return base.AuthorizeRequest(request);
- }
-
- ///
- /// Processes the hub's incoming method calls.
- ///
- protected override Task OnReceived(IRequest request, string connectionId, string data)
- {
- HubRequest hubRequest = _requestParser.Parse(data);
-
- // Create the hub
- HubDescriptor descriptor = _manager.EnsureHub(hubRequest.Hub,
- _counters.ErrorsHubInvocationTotal,
- _counters.ErrorsHubInvocationPerSec,
- _counters.ErrorsAllTotal,
- _counters.ErrorsAllPerSec);
-
- IJsonValue[] parameterValues = hubRequest.ParameterValues;
-
- // Resolve the method
- MethodDescriptor methodDescriptor = _manager.GetHubMethod(descriptor.Name, hubRequest.Method, parameterValues);
-
- if (methodDescriptor == null)
- {
- _counters.ErrorsHubInvocationTotal.Increment();
- _counters.ErrorsHubInvocationPerSec.Increment();
-
- // Empty (noop) method descriptor
- // Use: Forces the hub pipeline module to throw an error. This error is encapsulated in the HubDispatcher.
- // Encapsulating it in the HubDispatcher prevents the error from bubbling up to the transport level.
- // Specifically this allows us to return a faulted task (call .fail on client) and to not cause the
- // transport to unintentionally fail.
- methodDescriptor = new NullMethodDescriptor(hubRequest.Method);
- }
-
- // Resolving the actual state object
- var tracker = new StateChangeTracker(hubRequest.State);
- var hub = CreateHub(request, descriptor, connectionId, tracker, throwIfFailedToCreate: true);
-
- return InvokeHubPipeline(hub, parameterValues, methodDescriptor, hubRequest, tracker)
- .ContinueWith(task => hub.Dispose(), TaskContinuationOptions.ExecuteSynchronously);
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "Exceptions are flown to the caller.")]
- private Task InvokeHubPipeline(IHub hub,
- IJsonValue[] parameterValues,
- MethodDescriptor methodDescriptor,
- HubRequest hubRequest,
- StateChangeTracker tracker)
- {
- Task piplineInvocation;
-
- try
- {
- var args = _binder.ResolveMethodParameters(methodDescriptor, parameterValues);
- var context = new HubInvokerContext(hub, tracker, methodDescriptor, args);
-
- // Invoke the pipeline and save the task
- piplineInvocation = _pipelineInvoker.Invoke(context);
- }
- catch (Exception ex)
- {
- piplineInvocation = TaskAsyncHelper.FromError(ex);
- }
-
- // Determine if we have a faulted task or not and handle it appropriately.
- return piplineInvocation.ContinueWith(task =>
- {
- if (task.IsFaulted)
- {
- return ProcessResponse(tracker, result: null, request: hubRequest, error: task.Exception);
- }
- else if (task.IsCanceled)
- {
- return ProcessResponse(tracker, result: null, request: hubRequest, error: new OperationCanceledException());
- }
- else
- {
- return ProcessResponse(tracker, task.Result, hubRequest, error: null);
- }
- })
- .FastUnwrap();
- }
-
- public override Task ProcessRequest(HostContext context)
- {
- if (context == null)
- {
- throw new ArgumentNullException("context");
- }
-
- // Trim any trailing slashes
- string normalized = context.Request.Url.LocalPath.TrimEnd('/');
-
- if (normalized.EndsWith(HubsSuffix, StringComparison.OrdinalIgnoreCase))
- {
- // Generate the proper hub url
- string hubUrl = normalized.Substring(0, normalized.Length - HubsSuffix.Length);
-
- // Generate the proxy
- context.Response.ContentType = JsonUtility.JavaScriptMimeType;
- return context.Response.End(_proxyGenerator.GenerateProxy(hubUrl));
- }
-
- _isDebuggingEnabled = context.IsDebuggingEnabled();
-
- return base.ProcessRequest(context);
- }
-
- internal static Task Connect(IHub hub)
- {
- return hub.OnConnected();
- }
-
- internal static Task Reconnect(IHub hub)
- {
- return hub.OnReconnected();
- }
-
- internal static Task Disconnect(IHub hub)
- {
- return hub.OnDisconnected();
- }
-
- [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "A faulted task is returned.")]
- internal static Task Incoming(IHubIncomingInvokerContext context)
- {
- var tcs = new TaskCompletionSource();
-
- try
- {
- object result = context.MethodDescriptor.Invoker(context.Hub, context.Args.ToArray());
- Type returnType = context.MethodDescriptor.ReturnType;
-
- if (typeof(Task).IsAssignableFrom(returnType))
- {
- var task = (Task)result;
- if (!returnType.IsGenericType)
- {
- task.ContinueWith(tcs);
- }
- else
- {
- // Get the in Task
- Type resultType = returnType.GetGenericArguments().Single();
-
- Type genericTaskType = typeof(Task<>).MakeGenericType(resultType);
-
- // Get the correct ContinueWith overload
- var parameter = Expression.Parameter(typeof(object));
-
- // TODO: Cache this whole thing
- // Action callback = result => ContinueWith((Task)result, tcs);
- MethodInfo continueWithMethod = _continueWithMethod.MakeGenericMethod(resultType);
-
- Expression body = Expression.Call(continueWithMethod,
- Expression.Convert(parameter, genericTaskType),
- Expression.Constant(tcs));
-
- var continueWithInvoker = Expression.Lambda>(body, parameter).Compile();
- continueWithInvoker.Invoke(result);
- }
- }
- else
- {
- tcs.TrySetResult(result);
- }
- }
- catch (Exception ex)
- {
- tcs.TrySetUnwrappedException(ex);
- }
-
- return tcs.Task;
- }
-
- internal static Task Outgoing(IHubOutgoingInvokerContext context)
- {
- var message = new ConnectionMessage(context.Signal, context.Invocation, context.ExcludedSignals);
-
- return context.Connection.Send(message);
- }
-
- protected override Task OnConnected(IRequest request, string connectionId)
- {
- return ExecuteHubEvent(request, connectionId, hub => _pipelineInvoker.Connect(hub));
- }
-
- protected override Task OnReconnected(IRequest request, string connectionId)
- {
- return ExecuteHubEvent(request, connectionId, hub => _pipelineInvoker.Reconnect(hub));
- }
-
- protected override IList OnRejoiningGroups(IRequest request, IList groups, string connectionId)
- {
- return _hubs.Select(hubDescriptor =>
- {
- string groupPrefix = hubDescriptor.Name + ".";
-
- var hubGroups = groups.Where(g => g.StartsWith(groupPrefix, StringComparison.OrdinalIgnoreCase))
- .Select(g => g.Substring(groupPrefix.Length))
- .ToList();
-
- return _pipelineInvoker.RejoiningGroups(hubDescriptor, request, hubGroups)
- .Select(g => groupPrefix + g);
-
- }).SelectMany(groupsToRejoin => groupsToRejoin).ToList();
- }
-
- protected override Task OnDisconnected(IRequest request, string connectionId)
- {
- return ExecuteHubEvent(request, connectionId, hub => _pipelineInvoker.Disconnect(hub));
- }
-
- protected override IList GetSignals(string connectionId)
- {
- return _hubs.SelectMany(info => new[] { PrefixHelper.GetHubName(info.Name), PrefixHelper.GetHubConnectionId(info.CreateQualifiedName(connectionId)) })
- .Concat(new[] { PrefixHelper.GetConnectionId(connectionId), PrefixHelper.GetAck(connectionId) })
- .ToList();
- }
-
- private Task ExecuteHubEvent(IRequest request, string connectionId, Func action)
- {
- var hubs = GetHubs(request, connectionId).ToList();
- var operations = hubs.Select(instance => action(instance).OrEmpty().Catch()).ToArray();
-
- if (operations.Length == 0)
- {
- DisposeHubs(hubs);
- return TaskAsyncHelper.Empty;
- }
-
- var tcs = new TaskCompletionSource();
- Task.Factory.ContinueWhenAll(operations, tasks =>
- {
- DisposeHubs(hubs);
- var faulted = tasks.FirstOrDefault(t => t.IsFaulted);
- if (faulted != null)
- {
- tcs.SetUnwrappedException(faulted.Exception);
- }
- else if (tasks.Any(t => t.IsCanceled))
- {
- tcs.SetCanceled();
- }
- else
- {
- tcs.SetResult(null);
- }
- });
-
- return tcs.Task;
- }
-
- private IHub CreateHub(IRequest request, HubDescriptor descriptor, string connectionId, StateChangeTracker tracker = null, bool throwIfFailedToCreate = false)
- {
- try
- {
- var hub = _manager.ResolveHub(descriptor.Name);
-
- if (hub != null)
- {
- tracker = tracker ?? new StateChangeTracker();
-
- hub.Context = new HubCallerContext(request, connectionId);
- hub.Clients = new HubConnectionContext(_pipelineInvoker, Connection, descriptor.Name, connectionId, tracker);
- hub.Groups = new GroupManager(Connection, PrefixHelper.GetHubGroupName(descriptor.Name));
- }
-
- return hub;
- }
- catch (Exception ex)
- {
- Trace.TraceInformation(String.Format(CultureInfo.CurrentCulture, Resources.Error_ErrorCreatingHub + ex.Message, descriptor.Name));
-
- if (throwIfFailedToCreate)
- {
- throw;
- }
-
- return null;
- }
- }
-
- private IEnumerable GetHubs(IRequest request, string connectionId)
- {
- return from descriptor in _hubs
- select CreateHub(request, descriptor, connectionId) into hub
- where hub != null
- select hub;
- }
-
- private static void DisposeHubs(IEnumerable hubs)
- {
- foreach (var hub in hubs)
- {
- hub.Dispose();
- }
- }
-
- private Task ProcessResponse(StateChangeTracker tracker, object result, HubRequest request, Exception error)
- {
- var hubResult = new HubResponse
- {
- State = tracker.GetChanges(),
- Result = result,
- Id = request.Id,
- };
-
- if (error != null)
- {
- _counters.ErrorsHubInvocationTotal.Increment();
- _counters.ErrorsHubInvocationPerSec.Increment();
- _counters.ErrorsAllTotal.Increment();
- _counters.ErrorsAllPerSec.Increment();
-
- if (_enableDetailedErrors)
- {
- var exception = error.InnerException ?? error;
- hubResult.StackTrace = _isDebuggingEnabled ? exception.StackTrace : null;
- hubResult.Error = exception.Message;
- }
- else
- {
- hubResult.Error = String.Format(CultureInfo.CurrentCulture, Resources.Error_HubInvocationFailed, request.Hub, request.Method);
- }
- }
-
- return Transport.Send(hubResult);
- }
-
- private static void ContinueWith(Task task, TaskCompletionSource tcs)
- {
- if (task.IsCompleted)
- {
- // Fast path for tasks that completed synchronously
- ContinueSync(task, tcs);
- }
- else
- {
- ContinueAsync(task, tcs);
- }
- }
-
- private static void ContinueSync(Task task, TaskCompletionSource tcs)
- {
- if (task.IsFaulted)
- {
- tcs.TrySetUnwrappedException(task.Exception);
- }
- else if (task.IsCanceled)
- {
- tcs.TrySetCanceled();
- }
- else
- {
- tcs.TrySetResult(task.Result);
- }
- }
-
- private static void ContinueAsync(Task task, TaskCompletionSource tcs)
- {
- task.ContinueWith(t =>
- {
- if (t.IsFaulted)
- {
- tcs.TrySetUnwrappedException(t.Exception);
- }
- else if (t.IsCanceled)
- {
- tcs.TrySetCanceled();
- }
- else
- {
- tcs.TrySetResult(t.Result);
- }
- });
- }
-
- [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "It is instantiated through JSON deserialization.")]
- private class ClientHubInfo
- {
- public string Name { get; set; }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubMethodNameAttribute.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubMethodNameAttribute.cs
deleted file mode 100644
index 49166ce07..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubMethodNameAttribute.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = false)]
- public sealed class HubMethodNameAttribute : Attribute
- {
- public HubMethodNameAttribute(string methodName)
- {
- if (String.IsNullOrEmpty(methodName))
- {
- throw new ArgumentNullException("methodName");
- }
- MethodName = methodName;
- }
-
- public string MethodName
- {
- get;
- private set;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubNameAttribute.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubNameAttribute.cs
deleted file mode 100644
index 942c88706..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubNameAttribute.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
- public sealed class HubNameAttribute : Attribute
- {
- public HubNameAttribute(string hubName)
- {
- if (String.IsNullOrEmpty(hubName))
- {
- throw new ArgumentNullException("hubName");
- }
- HubName = hubName;
- }
-
- public string HubName
- {
- get;
- private set;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequest.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequest.cs
deleted file mode 100644
index 083d855cb..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequest.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class HubRequest
- {
- public string Hub { get; set; }
- public string Method { get; set; }
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This type is used for de-serialization.")]
- public IJsonValue[] ParameterValues { get; set; }
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This type is used for de-serialization.")]
- [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "This type is used for de-serialization.")]
- public IDictionary State { get; set; }
- public string Id { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequestParser.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequestParser.cs
deleted file mode 100644
index f5f361f41..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubRequestParser.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Linq;
-using Microsoft.AspNet.SignalR.Json;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubRequestParser : IHubRequestParser
- {
- private static readonly IJsonValue[] _emptyArgs = new IJsonValue[0];
-
- public HubRequest Parse(string data)
- {
- var serializer = new JsonNetSerializer();
- var deserializedData = serializer.Parse(data);
-
- var request = new HubRequest();
-
- request.Hub = deserializedData.Hub;
- request.Method = deserializedData.Method;
- request.Id = deserializedData.Id;
- request.State = GetState(deserializedData);
- request.ParameterValues = (deserializedData.Args != null) ? deserializedData.Args.Select(value => new JRawValue(value)).ToArray() : _emptyArgs;
-
- return request;
- }
-
- [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses", Justification = "This type is used for deserialzation")]
- private class HubInvocation
- {
- [JsonProperty("H")]
- public string Hub { get; set; }
- [JsonProperty("M")]
- public string Method { get; set; }
- [JsonProperty("I")]
- public string Id { get; set; }
- [JsonProperty("S")]
- public JRaw State { get; set; }
- [JsonProperty("A")]
- public JRaw[] Args { get; set; }
- }
-
- private static IDictionary GetState(HubInvocation deserializedData)
- {
- if (deserializedData.State == null)
- {
- return new Dictionary();
- }
-
- // Get the raw JSON string and check if it's over 4K
- string json = deserializedData.State.ToString();
-
- if (json.Length > 4096)
- {
- throw new InvalidOperationException(Resources.Error_StateExceededMaximumLength);
- }
-
- var settings = new JsonSerializerSettings();
- settings.Converters.Add(new SipHashBasedDictionaryConverter());
- var serializer = new JsonNetSerializer(settings);
- return serializer.Parse>(json);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubResponse.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/HubResponse.cs
deleted file mode 100644
index a1305eb9a..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/HubResponse.cs
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Newtonsoft.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// The response returned from an incoming hub request.
- ///
- public class HubResponse
- {
- ///
- /// The changes made the the round tripped state.
- ///
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "Type is used for serialization")]
- [JsonProperty("S", NullValueHandling = NullValueHandling.Ignore)]
- public IDictionary State { get; set; }
-
- ///
- /// The result of the invocation.
- ///
- [JsonProperty("R", NullValueHandling = NullValueHandling.Ignore)]
- public object Result { get; set; }
-
- ///
- /// The id of the operation.
- ///
- [JsonProperty("I")]
- public string Id { get; set; }
-
- ///
- /// The exception that occurs as a result of invoking the hub method.
- ///
- [JsonProperty("E", NullValueHandling = NullValueHandling.Ignore)]
- public string Error { get; set; }
-
- ///
- /// The stack trace of the exception that occurs as a result of invoking the hub method.
- ///
- [JsonProperty("T", NullValueHandling = NullValueHandling.Ignore)]
- public string StackTrace { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IAssemblyLocator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IAssemblyLocator.cs
deleted file mode 100644
index 5e98096fb..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IAssemblyLocator.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public interface IAssemblyLocator
- {
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Might be expensive.")]
- IList GetAssemblies();
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IClientProxy.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IClientProxy.cs
deleted file mode 100644
index 71c9bc69c..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IClientProxy.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// A server side proxy for the client side hub.
- ///
- public interface IClientProxy
- {
- ///
- /// Invokes a method on the connection(s) represented by the instance.
- ///
- /// name of the method to invoke
- /// argumetns to pass to the client
- /// A task that represents when the data has been sent to the client.
- Task Invoke(string method, params object[] args);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHub.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IHub.cs
deleted file mode 100644
index 1b7ef0ff8..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHub.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public interface IHub : IDisposable
- {
- ///
- /// Gets a . Which contains information about the calling client.
- ///
- HubCallerContext Context { get; set; }
-
- ///
- /// Gets a dynamic object that represents all clients connected to this hub (not hub instance).
- ///
- HubConnectionContext Clients { get; set; }
-
- ///
- /// Gets the the hub instance.
- ///
- IGroupManager Groups { get; set; }
-
- ///
- /// Called when a new connection is made to the .
- ///
- Task OnConnected();
-
- ///
- /// Called when a connection reconnects to the after a timeout.
- ///
- Task OnReconnected();
-
- ///
- /// Called when a connection is disconnected from the .
- ///
- Task OnDisconnected();
- }
-}
-
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubActivator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubActivator.cs
deleted file mode 100644
index 9a606a8a5..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubActivator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public interface IHubActivator
- {
- IHub Create(HubDescriptor descriptor);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubConnectionContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubConnectionContext.cs
deleted file mode 100644
index fa468dd47..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubConnectionContext.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Encapsulates all information about a SignalR connection for an .
- ///
- public interface IHubConnectionContext
- {
- dynamic All { get; }
- dynamic AllExcept(params string[] excludeConnectionIds);
- dynamic Client(string connectionId);
- dynamic Group(string groupName, params string[] excludeConnectionIds);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubRequestParser.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubRequestParser.cs
deleted file mode 100644
index dd798dd5f..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IHubRequestParser.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Handles parsing incoming requests through the .
- ///
- public interface IHubRequestParser
- {
- ///
- /// Parses the incoming hub payload into a .
- ///
- /// The raw hub payload.
- /// The resulting .
- HubRequest Parse(string data);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptMinifier.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptMinifier.cs
deleted file mode 100644
index 05690b5d7..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptMinifier.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public interface IJavaScriptMinifier
- {
- string Minify(string source);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptProxyGenerator.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptProxyGenerator.cs
deleted file mode 100644
index 49abbe3ea..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/IJavaScriptProxyGenerator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public interface IJavaScriptProxyGenerator
- {
- string GenerateProxy(string serviceUrl);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultHubManager.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultHubManager.cs
deleted file mode 100644
index f572b91e3..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultHubManager.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DefaultHubManager : IHubManager
- {
- private readonly IEnumerable _methodProviders;
- private readonly IHubActivator _activator;
- private readonly IEnumerable _hubProviders;
-
- public DefaultHubManager(IDependencyResolver resolver)
- {
- _hubProviders = resolver.ResolveAll();
- _methodProviders = resolver.ResolveAll();
- _activator = resolver.Resolve();
- }
-
- public HubDescriptor GetHub(string hubName)
- {
- HubDescriptor descriptor = null;
- if (_hubProviders.FirstOrDefault(p => p.TryGetHub(hubName, out descriptor)) != null)
- {
- return descriptor;
- }
-
- return null;
- }
-
- public IEnumerable GetHubs(Func predicate)
- {
- var hubs = _hubProviders.SelectMany(p => p.GetHubs());
-
- if (predicate != null)
- {
- return hubs.Where(predicate);
- }
-
- return hubs;
- }
-
- public MethodDescriptor GetHubMethod(string hubName, string method, IList parameters)
- {
- HubDescriptor hub = GetHub(hubName);
-
- if (hub == null)
- {
- return null;
- }
-
- MethodDescriptor descriptor = null;
- if (_methodProviders.FirstOrDefault(p => p.TryGetMethod(hub, method, out descriptor, parameters)) != null)
- {
- return descriptor;
- }
-
- return null;
- }
-
- public IEnumerable GetHubMethods(string hubName, Func predicate)
- {
- HubDescriptor hub = GetHub(hubName);
-
- if (hub == null)
- {
- return null;
- }
-
- var methods = _methodProviders.SelectMany(p => p.GetMethods(hub));
-
- if (predicate != null)
- {
- return methods.Where(predicate);
- }
-
- return methods;
-
- }
-
- public IHub ResolveHub(string hubName)
- {
- HubDescriptor hub = GetHub(hubName);
- return hub == null ? null : _activator.Create(hub);
- }
-
- public IEnumerable ResolveHubs()
- {
- return GetHubs(predicate: null).Select(hub => _activator.Create(hub));
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultParameterResolver.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultParameterResolver.cs
deleted file mode 100644
index 5b31a57f9..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/DefaultParameterResolver.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class DefaultParameterResolver : IParameterResolver
- {
- ///
- /// Resolves a parameter value based on the provided object.
- ///
- /// Parameter descriptor.
- /// Value to resolve the parameter value from.
- /// The parameter value.
- public virtual object ResolveParameter(ParameterDescriptor descriptor, IJsonValue value)
- {
- if (descriptor == null)
- {
- throw new ArgumentNullException("descriptor");
- }
-
- if (value == null)
- {
- throw new ArgumentNullException("value");
- }
-
- if (value.GetType() == descriptor.ParameterType)
- {
- return value;
- }
-
- return value.ConvertTo(descriptor.ParameterType);
- }
-
- ///
- /// Resolves method parameter values based on provided objects.
- ///
- /// Method descriptor.
- /// List of values to resolve parameter values from.
- /// Array of parameter values.
- public virtual IList ResolveMethodParameters(MethodDescriptor method, IList values)
- {
- if (method == null)
- {
- throw new ArgumentNullException("method");
- }
-
- return method.Parameters.Zip(values, ResolveParameter).ToArray();
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/Descriptor.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/Descriptor.cs
deleted file mode 100644
index 750a70965..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/Descriptor.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public abstract class Descriptor
- {
- ///
- /// Name of Descriptor.
- ///
- public virtual string Name { get; set; }
-
- ///
- /// Flags whether the name was specified.
- ///
- public virtual bool NameSpecified { get; set; }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/HubDescriptor.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/HubDescriptor.cs
deleted file mode 100644
index c4271eaef..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/HubDescriptor.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Holds information about a single hub.
- ///
- public class HubDescriptor : Descriptor
- {
- ///
- /// Hub type.
- ///
- public virtual Type HubType { get; set; }
-
- public string CreateQualifiedName(string unqualifiedName)
- {
- return Name + "." + unqualifiedName;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/MethodDescriptor.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/MethodDescriptor.cs
deleted file mode 100644
index 971f54f01..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/MethodDescriptor.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Holds information about a single hub method.
- ///
- public class MethodDescriptor : Descriptor
- {
- ///
- /// The return type of this method.
- ///
- public virtual Type ReturnType { get; set; }
-
- ///
- /// Hub descriptor object, target to this method.
- ///
- public virtual HubDescriptor Hub { get; set; }
-
- ///
- /// Available method parameters.
- ///
- [SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly", Justification = "This is supposed to be mutable")]
- public virtual IList Parameters { get; set; }
-
- ///
- /// Method invocation delegate.
- /// Takes a target hub and an array of invocation arguments as it's arguments.
- ///
- public virtual Func Invoker { get; set; }
-
- ///
- /// Attributes attached to this method.
- ///
- public virtual IEnumerable Attributes { get; set; }
- }
-}
-
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/NullMethodDescriptor.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/NullMethodDescriptor.cs
deleted file mode 100644
index d1617dbfb..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/NullMethodDescriptor.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class NullMethodDescriptor : MethodDescriptor
- {
- private static readonly IEnumerable _attributes = new List();
- private static readonly IList _parameters = new List();
-
- private string _methodName;
-
- public NullMethodDescriptor(string methodName)
- {
- _methodName = methodName;
- }
-
- public override Func Invoker
- {
- get
- {
- return (emptyHub, emptyParameters) =>
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_MethodCouldNotBeResolved, _methodName));
- };
- }
- }
-
- public override IList Parameters
- {
- get { return _parameters; }
- }
-
- public override IEnumerable Attributes
- {
- get { return _attributes; }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/ParameterDescriptor.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/ParameterDescriptor.cs
deleted file mode 100644
index 4e32d3a8b..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/Descriptors/ParameterDescriptor.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Holds information about a single hub method parameter.
- ///
- public class ParameterDescriptor
- {
- ///
- /// Parameter name.
- ///
- public virtual string Name { get; set; }
-
- ///
- /// Parameter type.
- ///
- public virtual Type ParameterType { get; set; }
- }
-}
-
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/HubMethodDispatcher.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/HubMethodDispatcher.cs
deleted file mode 100644
index c52b5e760..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/HubMethodDispatcher.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Linq.Expressions;
-using System.Reflection;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubMethodDispatcher
- {
- private HubMethodExecutor _executor;
-
- public HubMethodDispatcher(MethodInfo methodInfo)
- {
- _executor = GetExecutor(methodInfo);
- MethodInfo = methodInfo;
- }
-
- private delegate object HubMethodExecutor(IHub hub, object[] parameters);
-
- private delegate void VoidHubMethodExecutor(IHub hub, object[] parameters);
-
- public MethodInfo MethodInfo { get; private set; }
-
- public object Execute(IHub hub, object[] parameters)
- {
- return _executor(hub, parameters);
- }
-
- private static HubMethodExecutor GetExecutor(MethodInfo methodInfo)
- {
- // Parameters to executor
- ParameterExpression hubParameter = Expression.Parameter(typeof(IHub), "hub");
- ParameterExpression parametersParameter = Expression.Parameter(typeof(object[]), "parameters");
-
- // Build parameter list
- List parameters = new List();
- ParameterInfo[] paramInfos = methodInfo.GetParameters();
- for (int i = 0; i < paramInfos.Length; i++)
- {
- ParameterInfo paramInfo = paramInfos[i];
- BinaryExpression valueObj = Expression.ArrayIndex(parametersParameter, Expression.Constant(i));
- UnaryExpression valueCast = Expression.Convert(valueObj, paramInfo.ParameterType);
-
- // valueCast is "(Ti) parameters[i]"
- parameters.Add(valueCast);
- }
-
- // Call method
- UnaryExpression instanceCast = (!methodInfo.IsStatic) ? Expression.Convert(hubParameter, methodInfo.ReflectedType) : null;
- MethodCallExpression methodCall = Expression.Call(instanceCast, methodInfo, parameters);
-
- // methodCall is "((TController) hub) method((T0) parameters[0], (T1) parameters[1], ...)"
- // Create function
- if (methodCall.Type == typeof(void))
- {
- Expression lambda = Expression.Lambda(methodCall, hubParameter, parametersParameter);
- VoidHubMethodExecutor voidExecutor = lambda.Compile();
- return WrapVoidAction(voidExecutor);
- }
- else
- {
- // must coerce methodCall to match HubMethodExecutor signature
- UnaryExpression castMethodCall = Expression.Convert(methodCall, typeof(object));
- Expression lambda = Expression.Lambda(castMethodCall, hubParameter, parametersParameter);
- return lambda.Compile();
- }
- }
-
- private static HubMethodExecutor WrapVoidAction(VoidHubMethodExecutor executor)
- {
- return delegate(IHub hub, object[] parameters)
- {
- executor(hub, parameters);
- return null;
- };
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubDescriptorProvider.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubDescriptorProvider.cs
deleted file mode 100644
index e439d0b92..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubDescriptorProvider.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Describes hub descriptor provider, which provides information about available hubs.
- ///
- public interface IHubDescriptorProvider
- {
- ///
- /// Retrieve all avaiable hubs.
- ///
- /// Collection of hub descriptors.
- [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "This call might be expensive")]
- IList GetHubs();
-
- ///
- /// Tries to retrieve hub with a given name.
- ///
- /// Name of the hub.
- /// Retrieved descriptor object.
- /// True, if hub has been found
- bool TryGetHub(string hubName, out HubDescriptor descriptor);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubManager.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubManager.cs
deleted file mode 100644
index 99da9b351..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IHubManager.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Describes a hub manager - main point in the whole hub and method lookup process.
- ///
- public interface IHubManager
- {
- ///
- /// Retrieves a single hub descriptor.
- ///
- /// Name of the hub.
- /// Hub descriptor, if found. Null, otherwise.
- HubDescriptor GetHub(string hubName);
-
- ///
- /// Retrieves all available hubs matching the given predicate.
- ///
- /// List of hub descriptors.
- IEnumerable GetHubs(Func predicate);
-
- ///
- /// Resolves a given hub name to a concrete object.
- ///
- /// Name of the hub.
- /// Hub implementation instance, if found. Null otherwise.
- IHub ResolveHub(string hubName);
-
- ///
- /// Resolves all available hubs to their concrete objects.
- ///
- /// List of hub instances.
- IEnumerable ResolveHubs();
-
- ///
- /// Retrieves a method with a given name on a given hub.
- ///
- /// Name of the hub.
- /// Name of the method to find.
- /// Method parameters to match.
- /// Descriptor of the method, if found. Null otherwise.
- MethodDescriptor GetHubMethod(string hubName, string method, IList parameters);
-
- ///
- /// Gets all methods available to call on a given hub.
- ///
- /// Name of the hub,
- /// Optional predicate for filtering results.
- /// List of available methods.
- IEnumerable GetHubMethods(string hubName, Func predicate);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IMethodDescriptorProvider.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IMethodDescriptorProvider.cs
deleted file mode 100644
index ae0700f36..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IMethodDescriptorProvider.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Describes a hub method provider that builds a collection of available methods on a given hub.
- ///
- public interface IMethodDescriptorProvider
- {
- ///
- /// Retrieve all methods on a given hub.
- ///
- /// Hub descriptor object.
- /// Available methods.
- IEnumerable GetMethods(HubDescriptor hub);
-
- ///
- /// Tries to retrieve a method.
- ///
- /// Hub descriptor object
- /// Name of the method.
- /// Descriptor of the method, if found. Null otherwise.
- /// Method parameters to match.
- /// True, if a method has been found.
- [SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Justification = "This is a well known pattern for efficient lookup")]
- bool TryGetMethod(HubDescriptor hub, string method, out MethodDescriptor descriptor, IList parameters);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IParameterResolver.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IParameterResolver.cs
deleted file mode 100644
index e1ed36d61..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/IParameterResolver.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Describes a parameter resolver for resolving parameter-matching values based on provided information.
- ///
- public interface IParameterResolver
- {
- ///
- /// Resolves method parameter values based on provided objects.
- ///
- /// Method descriptor.
- /// List of values to resolve parameter values from.
- /// Array of parameter values.
- IList ResolveMethodParameters(MethodDescriptor method, IList values);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedHubDescriptorProvider.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedHubDescriptorProvider.cs
deleted file mode 100644
index 49b1e1d44..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedHubDescriptorProvider.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class ReflectedHubDescriptorProvider : IHubDescriptorProvider
- {
- private readonly Lazy> _hubs;
- private readonly Lazy _locator;
-
- public ReflectedHubDescriptorProvider(IDependencyResolver resolver)
- {
- _locator = new Lazy(resolver.Resolve);
- _hubs = new Lazy>(BuildHubsCache);
- }
-
- public IList GetHubs()
- {
- return _hubs.Value
- .Select(kv => kv.Value)
- .Distinct()
- .ToList();
- }
-
- public bool TryGetHub(string hubName, out HubDescriptor descriptor)
- {
- return _hubs.Value.TryGetValue(hubName, out descriptor);
- }
-
- protected IDictionary BuildHubsCache()
- {
- // Getting all IHub-implementing types that apply
- var types = _locator.Value.GetAssemblies()
- .SelectMany(GetTypesSafe)
- .Where(IsHubType);
-
- // Building cache entries for each descriptor
- // Each descriptor is stored in dictionary under a key
- // that is it's name or the name provided by an attribute
- var cacheEntries = types
- .Select(type => new HubDescriptor
- {
- NameSpecified = (type.GetHubAttributeName() != null),
- Name = type.GetHubName(),
- HubType = type
- })
- .ToDictionary(hub => hub.Name,
- hub => hub,
- StringComparer.OrdinalIgnoreCase);
-
- return cacheEntries;
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "If we throw then it's not a hub type")]
- private static bool IsHubType(Type type)
- {
- try
- {
- return typeof(IHub).IsAssignableFrom(type) &&
- !type.IsAbstract &&
- (type.Attributes.HasFlag(TypeAttributes.Public) ||
- type.Attributes.HasFlag(TypeAttributes.NestedPublic));
- }
- catch
- {
- return false;
- }
- }
-
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Justification = "If we throw then we have an empty type")]
- private static IEnumerable GetTypesSafe(Assembly a)
- {
- try
- {
- return a.GetTypes();
- }
- catch
- {
- return Enumerable.Empty();
- }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedMethodDescriptorProvider.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedMethodDescriptorProvider.cs
deleted file mode 100644
index db6b95756..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Lookup/ReflectedMethodDescriptorProvider.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Reflection;
-using Microsoft.AspNet.SignalR.Json;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class ReflectedMethodDescriptorProvider : IMethodDescriptorProvider
- {
- private readonly ConcurrentDictionary>> _methods;
- private readonly ConcurrentDictionary _executableMethods;
-
- public ReflectedMethodDescriptorProvider()
- {
- _methods = new ConcurrentDictionary>>(StringComparer.OrdinalIgnoreCase);
- _executableMethods = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase);
- }
-
- public IEnumerable GetMethods(HubDescriptor hub)
- {
- return FetchMethodsFor(hub)
- .SelectMany(kv => kv.Value)
- .ToList();
- }
-
- ///
- /// Retrieves an existing dictionary of all available methods for a given hub from cache.
- /// If cache entry does not exist - it is created automatically by BuildMethodCacheFor.
- ///
- ///
- ///
- private IDictionary> FetchMethodsFor(HubDescriptor hub)
- {
- return _methods.GetOrAdd(
- hub.Name,
- key => BuildMethodCacheFor(hub));
- }
-
- ///
- /// Builds a dictionary of all possible methods on a given hub.
- /// Single entry contains a collection of available overloads for a given method name (key).
- /// This dictionary is being cached afterwards.
- ///
- /// Hub to build cache for
- /// Dictionary of available methods
- private static IDictionary> BuildMethodCacheFor(HubDescriptor hub)
- {
- return ReflectionHelper.GetExportedHubMethods(hub.HubType)
- .GroupBy(GetMethodName, StringComparer.OrdinalIgnoreCase)
- .ToDictionary(group => group.Key,
- group => group.Select(oload =>
- new MethodDescriptor
- {
- ReturnType = oload.ReturnType,
- Name = group.Key,
- NameSpecified = (GetMethodAttributeName(oload) != null),
- Invoker = new HubMethodDispatcher(oload).Execute,
- Hub = hub,
- Attributes = oload.GetCustomAttributes(typeof(Attribute), inherit: true).Cast(),
- Parameters = oload.GetParameters()
- .Select(p => new ParameterDescriptor
- {
- Name = p.Name,
- ParameterType = p.ParameterType,
- })
- .ToList()
- }),
- StringComparer.OrdinalIgnoreCase);
- }
-
- ///
- /// Searches the specified Hub for the specified .
- ///
- ///
- /// In the case that there are multiple overloads of the specified , the parameter set helps determine exactly which instance of the overload should be resolved.
- /// If there are multiple overloads found with the same number of matching parameters, none of the methods will be returned because it is not possible to determine which overload of the method was intended to be resolved.
- ///
- /// Hub to search for the specified on.
- /// The method name to search for.
- /// If successful, the that was resolved.
- /// The set of parameters that will be used to help locate a specific overload of the specified .
- /// True if the method matching the name/parameter set is found on the hub, otherwise false.
- public bool TryGetMethod(HubDescriptor hub, string method, out MethodDescriptor descriptor, IList parameters)
- {
- string hubMethodKey = BuildHubExecutableMethodCacheKey(hub, method, parameters);
-
- if (!_executableMethods.TryGetValue(hubMethodKey, out descriptor))
- {
- IEnumerable overloads;
-
- if (FetchMethodsFor(hub).TryGetValue(method, out overloads))
- {
- var matches = overloads.Where(o => o.Matches(parameters)).ToList();
-
- // If only one match is found, that is the "executable" version, otherwise none of the methods can be returned because we don't know which one was actually being targeted
- descriptor = matches.Count == 1 ? matches[0] : null;
- }
- else
- {
- descriptor = null;
- }
-
- // If an executable method was found, cache it for future lookups (NOTE: we don't cache null instances because it could be a surface area for DoS attack by supplying random method names to flood the cache)
- if (descriptor != null)
- {
- _executableMethods.TryAdd(hubMethodKey, descriptor);
- }
- }
-
- return descriptor != null;
- }
-
- private static string BuildHubExecutableMethodCacheKey(HubDescriptor hub, string method, IList parameters)
- {
- string normalizedParameterCountKeyPart;
-
- if (parameters != null)
- {
- normalizedParameterCountKeyPart = parameters.Count.ToString(CultureInfo.InvariantCulture);
- }
- else
- {
- // NOTE: we normalize a null parameter array to be the same as an empty (i.e. Length == 0) parameter array
- normalizedParameterCountKeyPart = "0";
- }
-
- // NOTE: we always normalize to all uppercase since method names are case insensitive and could theoretically come in diff. variations per call
- string normalizedMethodName = method.ToUpperInvariant();
-
- string methodKey = hub.Name + "::" + normalizedMethodName + "(" + normalizedParameterCountKeyPart + ")";
-
- return methodKey;
- }
-
- private static string GetMethodName(MethodInfo method)
- {
- return GetMethodAttributeName(method) ?? method.Name;
- }
-
- private static string GetMethodAttributeName(MethodInfo method)
- {
- return ReflectionHelper.GetAttributeValue(method, a => a.MethodName);
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/NullClientProxy.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/NullClientProxy.cs
deleted file mode 100644
index 4d944017e..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/NullClientProxy.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Dynamic;
-using System.Globalization;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class NullClientProxy : DynamicObject
- {
- public override bool TryGetMember(GetMemberBinder binder, out object result)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_UsingHubInstanceNotCreatedUnsupported));
- }
-
- public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_UsingHubInstanceNotCreatedUnsupported));
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/NullJavaScriptMinifier.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/NullJavaScriptMinifier.cs
deleted file mode 100644
index 932d38d0a..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/NullJavaScriptMinifier.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Diagnostics.CodeAnalysis;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- public class NullJavaScriptMinifier : IJavaScriptMinifier
- {
- [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "This is a singleton")]
- public static readonly NullJavaScriptMinifier Instance = new NullJavaScriptMinifier();
-
- public string Minify(string source)
- {
- return source;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/AuthorizeModule.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/AuthorizeModule.cs
deleted file mode 100644
index 046e45cba..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/AuthorizeModule.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// This module is added the the HubPipeline by default.
- ///
- /// Hub level attributes that implement such as are applied to determine
- /// whether to allow potential clients to receive messages sent from that hub using a or a
- /// All applicable hub attributes must allow hub connection for the connection to be authorized.
- ///
- /// Hub and method level attributes that implement such as are applied
- /// to determine whether to allow callers to invoke hub methods.
- /// All applicable hub level AND method level attributes must allow hub method invocation for the invocation to be authorized.
- ///
- /// Optionally, this module may be instantiated with and
- /// authorizers that will be applied globally to all hubs and hub methods.
- ///
- public class AuthorizeModule : HubPipelineModule
- {
- // Global authorizers
- private readonly IAuthorizeHubConnection _globalConnectionAuthorizer;
- private readonly IAuthorizeHubMethodInvocation _globalInvocationAuthorizer;
-
- // Attribute authorizer caches
- private readonly ConcurrentDictionary> _connectionAuthorizersCache;
- private readonly ConcurrentDictionary> _classInvocationAuthorizersCache;
- private readonly ConcurrentDictionary> _methodInvocationAuthorizersCache;
-
- // By default, this module does not include any authorizers that are applied globally.
- // This module will always apply authorizers attached to hubs or hub methods
- public AuthorizeModule()
- : this(globalConnectionAuthorizer: null, globalInvocationAuthorizer: null)
- {
- }
-
- public AuthorizeModule(IAuthorizeHubConnection globalConnectionAuthorizer, IAuthorizeHubMethodInvocation globalInvocationAuthorizer)
- {
- // Set global authorizers
- _globalConnectionAuthorizer = globalConnectionAuthorizer;
- _globalInvocationAuthorizer = globalInvocationAuthorizer;
-
- // Initialize attribute authorizer caches
- _connectionAuthorizersCache = new ConcurrentDictionary>();
- _classInvocationAuthorizersCache = new ConcurrentDictionary>();
- _methodInvocationAuthorizersCache = new ConcurrentDictionary>();
- }
-
- public override Func BuildAuthorizeConnect(Func authorizeConnect)
- {
- return base.BuildAuthorizeConnect((hubDescriptor, request) =>
- {
- // Execute custom modules first and short circuit if any deny authorization.
- if (!authorizeConnect(hubDescriptor, request))
- {
- return false;
- }
-
- // Execute the global hub connection authorizer if there is one next and short circuit if it denies authorization.
- if (_globalConnectionAuthorizer != null && !_globalConnectionAuthorizer.AuthorizeHubConnection(hubDescriptor, request))
- {
- return false;
- }
-
- // Get hub attributes implementing IAuthorizeHubConnection from the cache
- // If the attributes do not exist in the cache, retrieve them using reflection and add them to the cache
- var attributeAuthorizers = _connectionAuthorizersCache.GetOrAdd(hubDescriptor.HubType,
- hubType => hubType.GetCustomAttributes(typeof(IAuthorizeHubConnection), inherit: true).Cast());
-
- // Every attribute (if any) implementing IAuthorizeHubConnection attached to the relevant hub MUST allow the connection
- return attributeAuthorizers.All(a => a.AuthorizeHubConnection(hubDescriptor, request));
- });
- }
-
- public override Func> BuildIncoming(Func> invoke)
- {
- return base.BuildIncoming(context =>
- {
- // Execute the global method invocation authorizer if there is one and short circuit if it denies authorization.
- if (_globalInvocationAuthorizer == null || _globalInvocationAuthorizer.AuthorizeHubMethodInvocation(context, appliesToMethod: false))
- {
- // Get hub attributes implementing IAuthorizeHubMethodInvocation from the cache
- // If the attributes do not exist in the cache, retrieve them using reflection and add them to the cache
- var classLevelAuthorizers = _classInvocationAuthorizersCache.GetOrAdd(context.Hub.GetType(),
- hubType => hubType.GetCustomAttributes(typeof(IAuthorizeHubMethodInvocation), inherit: true).Cast());
-
- // Execute all hub level authorizers and short circuit if ANY deny authorization.
- if (classLevelAuthorizers.All(a => a.AuthorizeHubMethodInvocation(context, appliesToMethod: false)))
- {
- // If the MethodDescriptor is a NullMethodDescriptor, we don't want to cache it since a new one is created
- // for each invocation with an invalid method name. #1801
- if (context.MethodDescriptor is NullMethodDescriptor)
- {
- return invoke(context);
- }
-
- // Get method attributes implementing IAuthorizeHubMethodInvocation from the cache
- // If the attributes do not exist in the cache, retrieve them from the MethodDescriptor and add them to the cache
- var methodLevelAuthorizers = _methodInvocationAuthorizersCache.GetOrAdd(context.MethodDescriptor,
- methodDescriptor => methodDescriptor.Attributes.OfType());
-
- // Execute all method level authorizers. If ALL provide authorization, continue executing the invocation pipeline.
- if (methodLevelAuthorizers.All(a => a.AuthorizeHubMethodInvocation(context, appliesToMethod: true)))
- {
- return invoke(context);
- }
- }
- }
-
- // Send error back to the client
- return TaskAsyncHelper.FromError(
- new NotAuthorizedException(String.Format(CultureInfo.CurrentCulture, Resources.Error_CallerNotAuthorizedToInvokeMethodOn,
- context.MethodDescriptor.Name,
- context.MethodDescriptor.Hub.Name)));
- });
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubConnection.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubConnection.cs
deleted file mode 100644
index c89e60014..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubConnection.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Interface to be implemented by s that can authorize client to connect to a .
- ///
- public interface IAuthorizeHubConnection
- {
- ///
- /// Given a , determine whether client is authorized to connect to .
- ///
- /// Description of the hub client is attempting to connect to.
- /// The connection request from the client.
- /// true if the caller is authorized to connect to the hub; otherwise, false.
- bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubMethodInvocation.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubMethodInvocation.cs
deleted file mode 100644
index 4d1eee752..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/IAuthorizeHubMethodInvocation.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- ///
- /// Interface to be implemented by s that can authorize the invocation of methods.
- ///
- public interface IAuthorizeHubMethodInvocation
- {
- ///
- /// Given a , determine whether client is authorized to invoke the method.
- ///
- /// An providing details regarding the method invocation.
- /// Indicates whether the interface instance is an attribute applied directly to a method.
- /// true if the caller is authorized to invoke the method; otherwise, false.
- bool AuthorizeHubMethodInvocation(IHubIncomingInvokerContext hubIncomingInvokerContext, bool appliesToMethod);
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/NotAuthorizedException.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/NotAuthorizedException.cs
deleted file mode 100644
index 10d32b649..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/Auth/NotAuthorizedException.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- [Serializable]
- public class NotAuthorizedException : Exception
- {
- public NotAuthorizedException() { }
- public NotAuthorizedException(string message) : base(message) { }
- public NotAuthorizedException(string message, Exception inner) : base(message, inner) { }
- protected NotAuthorizedException(
- System.Runtime.Serialization.SerializationInfo info,
- System.Runtime.Serialization.StreamingContext context)
- : base(info, context) { }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubInvokerContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubInvokerContext.cs
deleted file mode 100644
index eea40b052..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubInvokerContext.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubInvokerContext : IHubIncomingInvokerContext
- {
- public HubInvokerContext(IHub hub, StateChangeTracker tracker, MethodDescriptor methodDescriptor, IList args)
- {
- Hub = hub;
- MethodDescriptor = methodDescriptor;
- Args = args;
- StateTracker = tracker;
- }
-
- public IHub Hub
- {
- get;
- private set;
- }
-
- public MethodDescriptor MethodDescriptor
- {
- get;
- private set;
- }
-
- public IList Args
- {
- get;
- private set;
- }
-
-
- public StateChangeTracker StateTracker
- {
- get;
- private set;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubOutgoingInvokerContext.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubOutgoingInvokerContext.cs
deleted file mode 100644
index 8de9851f7..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubOutgoingInvokerContext.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System.Collections.Generic;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubOutgoingInvokerContext : IHubOutgoingInvokerContext
- {
- public HubOutgoingInvokerContext(IConnection connection, string signal, ClientHubInvocation invocation, IList excludedSignals)
- {
- Connection = connection;
- Signal = signal;
- Invocation = invocation;
- ExcludedSignals = excludedSignals;
- }
-
- public IConnection Connection
- {
- get;
- private set;
- }
-
- public ClientHubInvocation Invocation
- {
- get;
- private set;
- }
-
- public string Signal
- {
- get;
- private set;
- }
-
- public IList ExcludedSignals
- {
- get;
- private set;
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipeline.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipeline.cs
deleted file mode 100644
index 9cf6eccd4..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipeline.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Microsoft.AspNet.SignalR.Hubs
-{
- internal class HubPipeline : IHubPipeline, IHubPipelineInvoker
- {
- private readonly Stack _modules;
- private readonly Lazy _pipeline;
-
- public HubPipeline()
- {
- _modules = new Stack();
- _pipeline = new Lazy(() => new ComposedPipeline(_modules));
- }
-
- public IHubPipeline AddModule(IHubPipelineModule pipelineModule)
- {
- if (_pipeline.IsValueCreated)
- {
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_UnableToAddModulePiplineAlreadyInvoked));
- }
- _modules.Push(pipelineModule);
- return this;
- }
-
- private ComposedPipeline Pipeline
- {
- get { return _pipeline.Value; }
- }
-
- public Task Invoke(IHubIncomingInvokerContext context)
- {
- return Pipeline.Invoke(context);
- }
-
- public Task Connect(IHub hub)
- {
- return Pipeline.Connect(hub);
- }
-
- public Task Reconnect(IHub hub)
- {
- return Pipeline.Reconnect(hub);
- }
-
- public Task Disconnect(IHub hub)
- {
- return Pipeline.Disconnect(hub);
- }
-
- public bool AuthorizeConnect(HubDescriptor hubDescriptor, IRequest request)
- {
- return Pipeline.AuthorizeConnect(hubDescriptor, request);
- }
-
- public IList RejoiningGroups(HubDescriptor hubDescriptor, IRequest request, IList groups)
- {
- return Pipeline.RejoiningGroups(hubDescriptor, request, groups);
- }
-
- public Task Send(IHubOutgoingInvokerContext context)
- {
- return Pipeline.Send(context);
- }
-
- private class ComposedPipeline
- {
-
- public Func> Invoke;
- public Func Connect;
- public Func Reconnect;
- public Func Disconnect;
- public Func AuthorizeConnect;
- public Func, IList> RejoiningGroups;
- public Func Send;
-
- public ComposedPipeline(Stack modules)
- {
- // This wouldn't look nearly as gnarly if C# had better type inference, but now we don't need the ComposedModule or PassThroughModule.
- Invoke = Compose>>(modules, (m, f) => m.BuildIncoming(f))(HubDispatcher.Incoming);
- Connect = Compose>(modules, (m, f) => m.BuildConnect(f))(HubDispatcher.Connect);
- Reconnect = Compose>(modules, (m, f) => m.BuildReconnect(f))(HubDispatcher.Reconnect);
- Disconnect = Compose>(modules, (m, f) => m.BuildDisconnect(f))(HubDispatcher.Disconnect);
- AuthorizeConnect = Compose>(modules, (m, f) => m.BuildAuthorizeConnect(f))((h, r) => true);
- RejoiningGroups = Compose, IList>>(modules, (m, f) => m.BuildRejoiningGroups(f))((h, r, g) => g);
- Send = Compose>(modules, (m, f) => m.BuildOutgoing(f))(HubDispatcher.Outgoing);
- }
-
- // IHubPipelineModule could be turned into a second generic parameter, but it would make the above invocations even longer than they currently are.
- private static Func Compose(IEnumerable modules, Func method)
- {
- // Notice we are reversing and aggregating in one step. (Function composition is associative)
- return modules.Aggregate>(x => x, (a, b) => (x => method(b, a(x))));
- }
- }
- }
-}
diff --git a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipelineExtensions.cs b/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipelineExtensions.cs
deleted file mode 100644
index 0eaac77b8..000000000
--- a/src/Microsoft.AspNet.SignalR.Core/Hubs/Pipeline/HubPipelineExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.md in the project root for license information.
-
-using System;
-using Microsoft.AspNet.SignalR.Hubs;
-
-namespace Microsoft.AspNet.SignalR
-{
- public static class HubPipelineExtensions
- {
- ///
- /// Requiring Authentication adds an