private void TrySendViewRequestToFirstAvailableServer(Cluster cluster, HttpCommand httpCommand) { for (int i = 0; i < cluster.Servers.Count; i++) { var serverToUseForQuery = GetNextServerToUseForQuery(cluster); if (serverToUseForQuery.TrySend(httpCommand)) { return; } } httpCommand.NotifyComplete(ResponseStatus.DisconnectionOccuredBeforeResponseReceived); }
private void OnViewRequestError(string hostName, HttpCommand command) { var cluster = _cluster; if (GetHasQuit()) { command.NotifyComplete(ResponseStatus.DisconnectionOccuredBeforeResponseReceived); return; } TrySendViewRequestToFirstAvailableServer(cluster, command); }
private AsyncPatternResult<Stream, HttpCommand> OnBeginReadCompleted(IAsyncResult result, HttpCommand command) { var stream = command.HttpReadState.Stream; var bytesRead = stream.EndRead(result); if (bytesRead > 0 && command.OnRead(bytesRead) && command.HttpReadState.HasStillMoreBytesToRead) { return _readAsync.Continue(command.HttpReadState.Stream, command); } command.EndReading(); RemoveFromPendingCommands(command); command.NotifyComplete(); return _readAsync.Stop(); }