Beispiel #1
0
        public void Create(IReadOnlyList <Endpoint> endpts, bool hasMore, EndpointSelectionType selType,
                           ICreateConnectionCallback callback)
        {
            Debug.Assert(endpts.Count > 0);

            //
            // Apply the overrides.
            //
            IReadOnlyList <Endpoint> endpoints = ApplyOverrides(endpts).ToArray();

            //
            // Try to find a connection to one of the given endpoints.
            //
            try
            {
                Connection?connection = FindConnection(endpoints, out bool compress);
                if (connection != null)
                {
                    callback.SetConnection(connection, compress);
                    return;
                }
            }
            catch (System.Exception ex)
            {
                callback.SetException(ex);
                return;
            }
            var cb = new ConnectCallback(this, hasMore, callback, selType);

            // TODO: do something with the return value task
            _ = cb.GetConnectorsAsync(endpoints);
        }
Beispiel #2
0
 internal ConnectCallback(OutgoingConnectionFactory f, bool more, ICreateConnectionCallback cb,
                          EndpointSelectionType selType)
 {
     _factory  = f;
     _hasMore  = more;
     _callback = cb;
     _selType  = selType;
 }
Beispiel #3
0
            internal ConnectCallback(OutgoingConnectionFactory f, IReadOnlyList <Endpoint> endpoints, bool more,
                                     ICreateConnectionCallback cb, Ice.EndpointSelectionType selType)
            {
                Debug.Assert(endpoints.Count > 0);

                _factory            = f;
                _endpoints          = endpoints;
                _endpointEnumerator = _endpoints.GetEnumerator();
                _hasMoreEndpoints   = _endpointEnumerator.MoveNext();
                Debug.Assert(_hasMoreEndpoints); // even if there is only one endpoint, we have not read it yet with
                                                 // _endpointsEnumerator.Current
                _hasMore  = more;
                _callback = cb;
                _selType  = selType;
            }