internal bool TryAcceptConnection(IAsyncDvcChannel connection) { AssertAlive(); var connectionProxy = new ConnectionProxy(ServiceName, connection); try { connectionProxy.SetHandler(Target.AcceptConnection(connectionProxy.CallbackProxy)); return(true); } catch (COMException ex) when(ex.HResult == unchecked ((int)0x800706ba) /* RPC_S_SERVER_UNAVAILABLE */) { // caller needs to ditch this instance try { connection.SendMessage(Encoding.UTF8.GetBytes("ERROR Service is no longer available")); } catch (OperationCanceledException) { /* no-op */ } catch (ObjectDisposedException) { /* no-op */ } catch (DvcChannelDisconnectedException) { /* no-op */ } catch (Exception ex2) { Logger.Error(ex2, "Could not notify RDS endpoint of failed conncetion attempt"); } // this will tear down connection, too. connectionProxy.Dispose(); return(false); } catch (Exception ex) { try { connectionProxy.Dispose(); } catch (Exception ex2) { Logger.Error(ex2, $"Could not tear down new connection for {ServiceName}"); } Logger.Error(ex, $"Could not handle new connection for {ServiceName}"); return(true); } }
public ClientCallbackProxy(ConnectionProxy connectionProxy) { this.Parent = connectionProxy; }