示例#1
0
        public void HandleNewProxy()
        {
            var vcall = VcallSubsystem.New();
            var config = new HostingConfiguration();

            var peer = new HostingPeer(config, vcall);

            var info = new ProxyInfo
            {
                Tag = Guid.NewGuid().ToString(),
                ListeningUri = "/tests",
                NameSpace = "Vcall.Testing",
                HostName = "localhost"
            };

            var hosting = new Hosting(peer, vcall, config);
            hosting.HandleNewProxy(info);
        }
示例#2
0
文件: Engine.cs 项目: mamasha/hydra
        // user arbitrary thread
        HostingPeer IEngine.NewHostingPeer(HostingConfiguration config, VcallSubsystem core)
        {
            var timeout = TimeSpan.FromMilliseconds(_self.vconfig.Timeouts.HostingOpening);
            int addressInUseRetries = 0;

            for (;;)
            {
                var hosting = new HostingPeer(config, core);
                string uri = make_dynamic_uri(hosting.Tag, config.HostingRole);

                try
                {
                    hosting.Start(uri, timeout);
                    return hosting;
                }
                catch (Exception ex)
                {
                    if (ex.IsConsequenceOf<AddressAlreadyInUseException>())
                    {
                        addressInUseRetries++;

                        if (addressInUseRetries <= _self.vconfig.AddressInUseRetries)
                        {
                            warn("Dynamic URI '{0}' is in use; trying other one (retries={1})", uri, addressInUseRetries);
                            continue;
                        }

                        lock (_self.mutex)
                            _self.counters.Vcall_Error_AddressInUse++;

                        throw Helpers.MakeNew<VcallException>(ex, _log,
                            "hosting.{0}: Failed to listen on '{1}'; probably the TCP port is constantly in use (retries={2})", hosting.Tag, uri, addressInUseRetries);
                    }

                    lock (_self.mutex)
                        _self.counters.Vcall_Error_NewHostingFailed++;

                    throw;
                }
            }
        }