Пример #1
0
        //
        // Implementation of Reference.GetConnectionCallback
        //

        public void SetConnection(Ice.Connection connection, bool compress)
        {
            lock (this)
            {
                Debug.Assert(!_flushing && _exception == null && _connection == null);
                _connection = connection;
                _compress   = compress;
            }

            //
            // If this proxy is for a non-local object, and we are using a router, then
            // add this proxy to the router info object.
            //
            Debug.Assert(_proxy != null);
            RouterInfo?ri = _reference.GetRouterInfo();

            if (ri != null && !ri.AddProxy(_proxy, this))
            {
                return; // The request handler will be initialized once addProxy returns.
            }

            //
            // We can now send the queued requests.
            //
            FlushRequests();
        }
Пример #2
0
 dispatchCallback(Action callback, Ice.Connection conn)
 {
     if (_initData.dispatcher != null)
     {
         _initData.dispatcher(callback, conn);
     }
     else
     {
         callback();
     }
 }
Пример #3
0
 public override int InvokeRemote(Ice.Connection connection, bool compress, bool response)
 {
     CachedConnection = connection;
     return(connection.SendAsyncRequest(this, compress, response));
 }
Пример #4
0
 public abstract int InvokeRemote(Ice.Connection connection, bool compress, bool response);
Пример #5
0
 public void closed(Ice.Connection con)
 {
     called();
 }
Пример #6
0
        connected(RouterPrx router, SessionPrx session)
        {
            //
            // Remote invocation should be done without acquiring a mutex lock.
            //
            Debug.Assert(router != null);
            Ice.Connection conn       = router.GetCachedConnection();
            string         category   = router.getCategoryForClient();
            int            acmTimeout = 0;

            try
            {
                acmTimeout = router.getACMTimeout();
            }
            catch (OperationNotExistException)
            {
            }

            if (acmTimeout <= 0)
            {
                acmTimeout = (int)router.getSessionTimeout();
            }

            //
            // We create the callback object adapter here because createObjectAdapter internally
            // makes synchronous RPCs to the router. We can't create the OA on-demand when the
            // client calls objectAdapter() or addWithUUID() because they can be called from the
            // GUI thread.
            //
            if (_useCallbacks)
            {
                Debug.Assert(_adapter == null);
                _adapter = _communicator.createObjectAdapterWithRouter("", router);
                _adapter.Activate();
            }

            lock (_mutex)
            {
                _router = router;

                if (_destroy)
                {
                    //
                    // Run destroyInternal in a thread because it makes remote invocations.
                    //
                    Thread t = new Thread(new ThreadStart(destroyInternal));
                    t.Start();
                    return;
                }

                //
                // Cache the category.
                //
                _category = category;

                //
                // Assign the session after _destroy is checked.
                //
                _session   = session;
                _connected = true;

                if (acmTimeout > 0)
                {
                    Ice.Connection connection = _router.GetCachedConnection();
                    Debug.Assert(connection != null);
                    connection.setACM(acmTimeout, Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways);
                    connection.setCloseCallback(_ => destroy());
                }
            }

            dispatchCallback(() =>
            {
                try
                {
                    _callback.connected(this);
                }
                catch (SessionNotExistException)
                {
                    destroy();
                }
            }, conn);
        }