/// <summary> /// Opens a connection to the given usenet server on the specified port, and whether or not to use ssl. /// </summary> /// <param name="hostname">Usenet hostname</param> /// <param name="port">Port to connect on</param> /// <param name="ssl">Uses a secure connection if true</param> public void Connect(string hostname, int port, bool ssl) { conn = new Connection(hostname, port, ssl); var reply = ServerReply.Parse(conn.ReadLine()); Connected = reply.IsGood; }
public ServerReply WriteLine(string line, params object[] args) { w.WriteLine(line, args); string result = ReadLine(); var reply = ServerReply.Parse(result); return(reply); }
private Article ProcessArticle(ServerReply result, bool bodyOnly) { IBinaryDecoder decoder; if (result.IsGood) { Dictionary <string, string> dict; if (bodyOnly) { dict = new Dictionary <string, string>(); conn.ReadLine(); } else { dict = ReadHeader(); } decoder = DecoderFactory.DetermineDecoder(conn); if (decoder == null) { throw new Exception("Unable to determine binary post encoding."); } decoder.Decode( d => DownloadedChunk(this, new DownloadProgressEventArgs(d.BytesRead, d.Size, d.Filename, d.Part, d.TotalParts)) ); return(new Article { Headers = dict, Body = decoder.Result, Filename = decoder.Filename, Part = decoder.Part, TotalParts = decoder.TotalParts, ExpectedCrc32 = decoder.ExpectedCrc32, ActualCrc32 = decoder.ActualCrc32, Start = decoder.ByteOffset }); } return(null); }
private Article ProcessArticle(ServerReply result, bool bodyOnly) { IBinaryDecoder decoder; if(result.IsGood) { Dictionary<string, string> dict; if(bodyOnly) { dict = new Dictionary<string, string>(); conn.ReadLine(); } else { dict = ReadHeader(); } decoder = DecoderFactory.DetermineDecoder(conn); if(decoder == null) { throw new Exception("Unable to determine binary post encoding."); } decoder.Decode( d => DownloadedChunk(this, new DownloadProgressEventArgs(d.BytesRead, d.Size, d.Filename, d.Part, d.TotalParts)) ); return new Article { Headers = dict, Body = decoder.Result, Filename = decoder.Filename, Part = decoder.Part, TotalParts = decoder.TotalParts, ExpectedCrc32 = decoder.ExpectedCrc32, ActualCrc32 = decoder.ActualCrc32, Start = decoder.ByteOffset }; } return null; }