Ejemplo n.º 1
0
        public void SetRouterInfo(RouterInfo routerInfo)
        {
            Debug.Assert(routerInfo != null);
            ObjectAdapter?           adapter   = routerInfo.Adapter;
            IReadOnlyList <Endpoint> endpoints = routerInfo.GetClientEndpoints(); // Must be called outside the synchronization

            lock (this)
            {
                if (_destroyed)
                {
                    throw new CommunicatorDestroyedException();
                }

                //
                // Search for connections to the router's client proxy
                // endpoints, and update the object adapter for such
                // connections, so that callbacks from the router can be
                // received over such connections.
                //
                for (int i = 0; i < endpoints.Count; ++i)
                {
                    Endpoint endpoint = endpoints[i];

                    //
                    // Modify endpoints with overrides.
                    //
                    if (_communicator.OverrideTimeout != null)
                    {
                        endpoint = endpoint.NewTimeout(_communicator.OverrideTimeout.Value);
                    }

                    //
                    // The ConnectionI object does not take the compression flag of
                    // endpoints into account, but instead gets the information
                    // about whether messages should be compressed or not from
                    // other sources. In order to allow connection sharing for
                    // endpoints that differ in the value of the compression flag
                    // only, we always set the compression flag to false here in
                    // this connection factory.
                    //
                    endpoint = endpoint.NewCompressionFlag(false);

                    foreach (ICollection <Connection> connections in _connections.Values)
                    {
                        foreach (Connection connection in connections)
                        {
                            if (connection.Endpoint == endpoint)
                            {
                                connection.Adapter = adapter;
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
    public override ZeroC.Ice.Endpoint NewTimeout(int timeout)
    {
        var endpoint = _endpoint.NewTimeout(timeout);

        if (endpoint == _endpoint)
        {
            return(this);
        }
        else
        {
            return(new Endpoint(endpoint));
        }
    }
Ejemplo n.º 3
0
        public IncomingConnectionFactory(ObjectAdapter adapter, Endpoint endpoint, Endpoint?publish,
                                         ACMConfig acmConfig)
        {
            _communicator      = adapter.Communicator;
            _endpoint          = endpoint;
            _publishedEndpoint = publish;
            _adapter           = adapter;
            _warn    = _communicator.GetPropertyAsBool("Ice.Warn.Connections") ?? false;
            _monitor = new FactoryACMMonitor(_communicator, acmConfig);

            if (_communicator.OverrideTimeout != null)
            {
                _endpoint = _endpoint.NewTimeout(_communicator.OverrideTimeout.Value);
            }

            if (_communicator.OverrideCompress != null)
            {
                _endpoint = _endpoint.NewCompressionFlag(_communicator.OverrideCompress.Value);
            }

            try
            {
                _transceiver = _endpoint.GetTransceiver();
                if (_transceiver != null)
                {
                    if (_communicator.TraceLevels.Network >= 2)
                    {
                        _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat,
                                                   $"attempting to bind to {_endpoint.Name} socket\n{_transceiver}");
                    }
                    _endpoint = _transceiver.Bind();

                    var connection = new Connection(_communicator, null, _transceiver, null, _endpoint, _adapter);
                    _ = connection.StartAsync();
                    _connections.Add(connection);
                }
                else
                {
                    _acceptor = _endpoint.GetAcceptor(_adapter !.Name);

                    if (_communicator.TraceLevels.Network >= 2)
                    {
                        _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat,
                                                   $"attempting to bind to {_endpoint.Name} socket {_acceptor}");
                    }
                    _endpoint = _acceptor !.Listen();

                    if (_communicator.TraceLevels.Network >= 1)
                    {
                        _communicator.Logger.Trace(_communicator.TraceLevels.NetworkCat,
                                                   $"listening for {_endpoint.Name} connections\n{_acceptor!.ToDetailedString()}");
                    }
                }
            }
            catch (System.Exception)
            {
                //
                // Clean up.
                //
                try
                {
                    _transceiver?.Close();
                    _acceptor?.Close();
                }
                catch (System.Exception)
                {
                    // Ignore
                }

                _monitor.Destroy();
                _connections.Clear();

                throw;
            }
        }
Ejemplo n.º 4
0
 public override Endpoint NewTimeout(int timeout) =>
 timeout == _delegate.Timeout ? this : new WSEndpoint(_instance, _delegate.NewTimeout(timeout), Resource);