Esempio n. 1
0
        public SampleSignalRServer(int httpPort, int netMQPort, IEnumerable <int> subscriberPorts)
        {
            string serverUrl           = string.Format("http://localhost:{0}", httpPort);
            string netMQAddress        = string.Format("tcp://127.0.0.1:{0}", netMQPort);
            var    subscriberAddresses = subscriberPorts
                                         .Select(p => string.Format("tcp://127.0.0.1:{0}", p))
                                         .ToArray();
            var config = new NetMQScaleoutConfiguration(netMQAddress, subscriberAddresses);

            _httpServer = WebApp.Start(serverUrl, app =>
            {
                var resolver = new DefaultDependencyResolver();
                resolver.UseNetMQServiceBus(config);
                var assemblyLocator = new AssemblyLocator();
                resolver.Register(typeof(IAssemblyLocator), () => assemblyLocator);
                var hubConfiguration = new HubConfiguration
                {
                    Resolver = resolver,
                };
                app.MapSignalR(hubConfiguration);
            });
        }