Ejemplo n.º 1
0
        private void ConnectImpl(Func <IRouterPrx, ISessionPrx> factory)
        {
            Debug.Assert(!_destroy);
            new Thread(new ThreadStart(() =>
            {
                try
                {
                    lock (_mutex)
                    {
                        _communicator = new Communicator(_properties,
                                                         logger: _logger,
                                                         observer: _observer,
                                                         tlsClientOptions: _tlsClientOptions,
                                                         tlsServerOptions: _tlsServerOptions);
                    }
                }
                catch (Exception ex)
                {
                    lock (_mutex)
                    {
                        _destroy = true;
                    }
                    _callback.ConnectFailed(this, ex);
                    return;
                }

                if (_communicator.DefaultRouter == null)
                {
                    IRouterFinderPrx?finder = null;
                    try
                    {
                        finder = IRouterFinderPrx.Parse(_finderStr, _communicator);
                        _communicator.DefaultRouter = finder.GetRouter();
                    }
                    catch (CommunicatorDisposedException ex)
                    {
                        _callback.ConnectFailed(this, ex);
                        return;
                    }
                    catch (Exception ex)
                    {
                        if (finder == null)
                        {
                            _callback.ConnectFailed(this, ex);
                            return;
                        }
                        else
                        {
                            // In case of error getting router identity from RouterFinder use default identity.
                            _communicator.DefaultRouter =
                                finder.Clone(Ice.IRouterPrx.Factory, identity: new Identity("router", "Glacier2"));
                        }
                    }
                }

                try
                {
                    _callback.CreatedCommunicator(this);
                    IRouterPrx routerPrx = _communicator.DefaultRouter !.Clone(IRouterPrx.Factory);
                    ISessionPrx session  = factory(routerPrx);
                    Connected(routerPrx, session);
                }
                catch (Exception ex)
                {
                    _communicator.Dispose();
                    _callback.ConnectFailed(this, ex);
                }
            })).Start();
        }
Ejemplo n.º 2
0
        private void ConnectImpl(Func <IRouterPrx, ISessionPrx> factory)
        {
            Debug.Assert(!_destroy);
            new Thread(new ThreadStart(() =>
            {
                try
                {
                    lock (_mutex)
                    {
                        _communicator = new Communicator(
                            properties: _properties,
                            logger: _logger,
                            observer: _observer,
                            certificates: _certificates,
                            caCertificates: _caCertificates,
                            certificateSelectionCallback: _certificateSelectionCallback,
                            certificateValidationCallback: _certificateValidationCallback,
                            passwordCallback: _passwordCallback);
                    }
                }
                catch (Exception ex)
                {
                    lock (_mutex)
                    {
                        _destroy = true;
                    }
                    _callback.ConnectFailed(this, ex);
                    return;
                }

                if (_communicator.DefaultRouter == null)
                {
                    IRouterFinderPrx?finder = null;
                    try
                    {
                        finder = IRouterFinderPrx.Parse(_finderStr, _communicator);
                        _communicator.DefaultRouter = finder.GetRouter();
                    }
                    catch (CommunicatorDestroyedException ex)
                    {
                        _callback.ConnectFailed(this, ex);
                        return;
                    }
                    catch (Exception ex)
                    {
                        if (finder == null)
                        {
                            _callback.ConnectFailed(this, ex);
                            return;
                        }
                        else
                        {
                            // In case of error getting router identity from RouterFinder use default identity.
                            _communicator.DefaultRouter =
                                finder.Clone(new Identity("router", "Glacier2"), Ice.IRouterPrx.Factory);
                        }
                    }
                }

                try
                {
                    _callback.CreatedCommunicator(this);
                    Ice.IRouterPrx?defaultRouter = _communicator.DefaultRouter;
                    Debug.Assert(defaultRouter != null);
                    var routerPrx       = IRouterPrx.UncheckedCast(defaultRouter);
                    ISessionPrx session = factory(routerPrx);
                    Connected(routerPrx, session);
                }
                catch (Exception ex)
                {
                    _communicator.Destroy();
                    _callback.ConnectFailed(this, ex);
                }
            })).Start();
        }