protected virtual Task<bool> OnMessageReceived(PersistentResponse response)
{
if (response == null)
{
throw new ArgumentNullException("response");
}
response.Reconnect = HostShutdownToken.IsCancellationRequested;
if (IsTimedOut || response.Aborted)
{
_busRegistration.Dispose();
if (response.Aborted)
{
// If this was a clean disconnect raise the event.
return Abort().Then(() => TaskAsyncHelper.False);
}
}
if (response.Terminal)
{
// End the request on the terminal response
_transportLifetime.Complete();
return TaskAsyncHelper.False;
}
// Ensure delegate continues to use the C# Compiler static delegate caching optimization.
return Send(response).Then(() => TaskAsyncHelper.True);
}