示例#1
0
        private void Configure(IOwinConfiguration owin)
        {
            if (owin == null)
            {
                throw new ArgumentNullException(nameof(owin));
            }

            owin.Http.Routes.IgnoreRoute("signalR", "signalr/{*pathInfo}");

            IDependencyResolver resolver =
                GlobalHost.DependencyResolver =
                    new CustomResolver(GlobalHost.DependencyResolver, owin.Kernel);

            var hubConfiguration = new HubConfiguration
            {
                Resolver                = resolver,
                EnableDetailedErrors    = _enableDetailedErrors,
                EnableJavaScriptProxies = _enableJavaScriptProxies,
                EnableJSONP             = _enableJSONP
            };

            resolver.Register(typeof(IAssemblyLocator), () => new CustomAssemblyLocator(_assemblies));
            resolver.Register(typeof(IHubActivator), () => new CustomHubActivator(resolver));
            resolver.Register(typeof(IHubDescriptorProvider), () => new CustomHubDescriptorProvider(resolver, owin.Kernel.Resolve <IHubsProvider>()));

            IHubPipeline hubPipeline = resolver.Resolve <IHubPipeline>();

            foreach (var pipelineModule in owin.Kernel.ResolveAll <IHubPipelineModule>())
            {
                hubPipeline.AddModule(pipelineModule);
            }

            owin.App.Map(_path, subApp =>
            {
                _onMap?.Invoke(subApp);

                subApp.RunSignalR(hubConfiguration);
            });

            // TODO: Look at the possibility to add custom trace sources programatically
            // https://msdn.microsoft.com/en-us/library/ms228984(v=vs.110).aspx

            if (!_skipTraceConfiguration)
            {
                ITraceManager traceManager = resolver.Resolve <ITraceManager>();
                traceManager.Switch.Level = _traceLevel;
            }
        }
示例#2
0
            public IHub Create(HubDescriptor descriptor)
            {
                if (descriptor == null)
                {
                    throw new ArgumentNullException(nameof(descriptor));
                }

                if (descriptor.HubType == null)
                {
                    return(null);
                }

                return(_resolver.Resolve(descriptor.HubType) as IHub);
            }
        public SignalRMessageSender(IMessageContentFormatter formatter, Microsoft.AspNet.SignalR.IDependencyResolver signalRDependencyResolver)
        {
            if (formatter == null)
            {
                throw new ArgumentNullException(nameof(formatter));
            }

            if (signalRDependencyResolver == null)
            {
                throw new ArgumentNullException(nameof(signalRDependencyResolver));
            }

            _formatter         = formatter;
            _connectionManager = signalRDependencyResolver.Resolve <IConnectionManager>();
        }