Exemplo n.º 1
0
        connected(RouterPrx router, SessionPrx session)
        {
            string category = router.getCategoryForClient();
            long   timeout  = router.getSessionTimeout();

            Ice.Connection conn = router.ice_getCachedConnection();
            lock (this)
            {
                _router = router;

                if (_destroy)
                {
                    //
                    // Run the destroyInternal in a thread. This is because it
                    // destroyInternal 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;

                Debug.Assert(_sessionRefresh == null);
                if (timeout > 0)
                {
                    _sessionRefresh = new SessionRefreshThread(this, _router, (int)(timeout * 1000) / 2);
                    _refreshThread  = new Thread(new ThreadStart(_sessionRefresh.run));
                    _refreshThread.Start();
                }
            }

            dispatchCallback(delegate()
            {
                try
                {
                    _callback.connected(this);
                }
                catch (Glacier2.SessionNotExistException)
                {
                    destroy();
                }
            }, conn);
        }
Exemplo n.º 2
0
        connected(RouterPrx router, SessionPrx session)
        {
            //
            // Remote invocation should be done without acquiring a mutex lock.
            //
            Debug.Assert(router != null);
            Ice.Connection conn       = router.ice_getCachedConnection();
            string         category   = router.getCategoryForClient();
            int            acmTimeout = 0;

            try
            {
                acmTimeout = router.getACMTimeout();
            }
            catch (Ice.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.ice_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);
        }
Exemplo n.º 3
0
    connected(RouterPrx router, SessionPrx session)
    {
        //
        // Remote invocation should be done without acquiring a mutex lock.
        //
        Debug.Assert(router != null);
        Ice.Connection conn = router.ice_getCachedConnection();
        string category = router.getCategoryForClient();
        int acmTimeout = 0;
        try
        {
            acmTimeout = router.getACMTimeout();
        }
        catch(Ice.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(this)
        {
            _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.ice_getCachedConnection();
                Debug.Assert(connection != null);
                connection.setACM(acmTimeout, Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways);
                connection.setCloseCallback(_ => destroy());
            }
        }

        dispatchCallback(() =>
            {
                try
                {
                    _callback.connected(this);
                }
                catch(Glacier2.SessionNotExistException)
                {
                    destroy();
                }
            }, conn);
    }
Exemplo n.º 4
0
    connected(RouterPrx router, SessionPrx session)
    {
        string category = router.getCategoryForClient();
        long sessionTimeout = router.getSessionTimeout();
        int acmTimeout = 0;
        try
        {
            acmTimeout = router.getACMTimeout();
        }
        catch(Ice.OperationNotExistException)
        {
        }
        Ice.Connection conn = router.ice_getCachedConnection();

        lock(this)
        {
            _router = router;

            if(_destroy)
            {
                //
                // Run the destroyInternal in a thread. This is because it
                // destroyInternal 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.ice_getCachedConnection();
                Debug.Assert(connection != null);
                connection.setACM(acmTimeout, Ice.Util.None, Ice.ACMHeartbeat.HeartbeatAlways);
                connection.setCallback(new ConnectionCallbackI(this));
            }
            else if(sessionTimeout > 0)
            {
                IceInternal.Timer timer = IceInternal.Util.getInstance(communicator()).timer();
                timer.scheduleRepeated(new SessionRefreshTask(this, _router), (sessionTimeout * 1000)/2);
            }
        }

        dispatchCallback(() =>
            {
                try
                {
                    _callback.connected(this);
                }
                catch(Glacier2.SessionNotExistException)
                {
                    destroy();
                }
            }, conn);
    }
Exemplo n.º 5
0
    connected(RouterPrx router, SessionPrx session)
    {
        string category = router.getCategoryForClient();
        long timeout = router.getSessionTimeout();
        Ice.Connection conn = router.ice_getCachedConnection();
        lock(this)
        {
            _router = router;

            if(_destroy)
            {
                //
                // Run the destroyInternal in a thread. This is because it
                // destroyInternal 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;

            Debug.Assert(_sessionRefresh == null);
            if(timeout > 0)
            {
                _sessionRefresh = new SessionRefreshThread(this, _router, (int)(timeout * 1000)/2);
                _refreshThread = new Thread(new ThreadStart(_sessionRefresh.run));
                _refreshThread.Start();
            }
        }

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