void ProcessCommand(Pop3Command pc) { string response, text; byte[] buf; buf = Encoding.UTF8.GetBytes(pc.Command + "\r\n"); stream.Write(buf, 0, buf.Length); try { response = ReadLine(pc.CancellationToken).TrimEnd(); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } pc.Status = GetCommandStatus(response, out text); switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect(); throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { pc.Handler(this, pc, text); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } } break; } }
async Task ReadResponseAsync(Pop3Command pc, bool doAsync) { string response, text; try { response = (await ReadLineAsync(doAsync, pc.CancellationToken).ConfigureAwait(false)).TrimEnd(); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } pc.Status = GetCommandStatus(response, out text); pc.StatusText = text; switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect(); throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { await pc.Handler(this, pc, text, doAsync).ConfigureAwait(false); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } } break; } }
void ReadResponse(Pop3Command pc) { string response, text; try { response = ReadLine(pc.CancellationToken).TrimEnd(); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } pc.Status = GetCommandStatus(response, out text); pc.StatusText = text; switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect(); throw new Pop3ProtocolException(string.Format("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { pc.Handler(this, pc, text); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect(); throw; } } break; } }
void ProcessCommand(Pop3Command pc) { string response, text; byte[] buf; buf = Encoding.UTF8.GetBytes (pc.Command + "\r\n"); stream.Write (buf, 0, buf.Length); try { response = ReadLine (pc.CancellationToken).TrimEnd (); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect (); throw; } pc.Status = GetCommandStatus (response, out text); switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect (); throw new Pop3ProtocolException (string.Format ("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { pc.Handler (this, pc, text); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect (); throw; } } break; } }
void ReadResponse (Pop3Command pc) { string response, text; try { response = ReadLine (pc.CancellationToken).TrimEnd (); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect (); throw; } pc.Status = GetCommandStatus (response, out text); pc.StatusText = text; switch (pc.Status) { case Pop3CommandStatus.ProtocolError: Disconnect (); throw new Pop3ProtocolException (string.Format ("Unexpected response from server: {0}", response)); case Pop3CommandStatus.Continue: case Pop3CommandStatus.Ok: if (pc.Handler != null) { try { pc.Handler (this, pc, text); } catch { pc.Status = Pop3CommandStatus.ProtocolError; Disconnect (); throw; } } break; } }