private void Connected(IRouterPrx router, ISessionPrx session) { // Remote invocation should be done without acquiring a mutex lock. Debug.Assert(router != null); Debug.Assert(_communicator != null); // 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(); } string category = router.GetCategoryForClient(); lock (_mutex) { _router = router; if (_destroy) { // Run destroyInternal in a thread because it makes remote invocations. var 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; } // When using Ice1, we need to figure out the router's acm/session timeout and configure the connection // accordingly. With Ice2, this is no longer necessary, the idle timeout is negotiated on connection // establishment. Connection connection = router.GetConnection(); if (router.Protocol == Protocol.Ice1) { TimeSpan idleTimeout = TimeSpan.Zero; try { idleTimeout = TimeSpan.FromSeconds(router.GetACMTimeout()); } catch (OperationNotExistException) { } if (idleTimeout == TimeSpan.Zero) { idleTimeout = TimeSpan.FromSeconds(router.GetSessionTimeout()); } if (idleTimeout != TimeSpan.Zero) { connection.IdleTimeout = idleTimeout; } } connection.Closed += (sender, args) => Destroy(); try { _callback.Connected(this); } catch (SessionNotExistException) { Destroy(); } }
Connected(IRouterPrx router, ISessionPrx session) { // // Remote invocation should be done without acquiring a mutex lock. // Debug.Assert(router != null); Debug.Assert(_communicator != null); 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. // var 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) { Connection?connection = _router.GetCachedConnection(); Debug.Assert(connection != null); connection.SetACM(acmTimeout, null, ACMHeartbeat.HeartbeatAlways); connection.SetCloseCallback(_ => Destroy()); } } try { _callback.Connected(this); } catch (SessionNotExistException) { Destroy(); } }
private void Connected(IRouterPrx router, ISessionPrx session) { // Remote invocation should be done without acquiring a mutex lock. Debug.Assert(router != null); Debug.Assert(_communicator != null); Connection?conn = router.GetCachedConnection(); string category = router.GetCategoryForClient(); TimeSpan acmTimeout = TimeSpan.Zero; try { acmTimeout = TimeSpan.FromSeconds(router.GetACMTimeout()); } catch (OperationNotExistException) { } if (acmTimeout == TimeSpan.Zero) { acmTimeout = TimeSpan.FromSeconds(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. var 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 != TimeSpan.Zero) { Connection?connection = _router.GetCachedConnection(); Debug.Assert(connection != null); connection.Acm = new Acm(acmTimeout, connection.Acm.Close, AcmHeartbeat.Always); connection.Closed += (sender, args) => Destroy(); } } try { _callback.Connected(this); } catch (SessionNotExistException) { Destroy(); } }