Skip to content

Commit

Permalink
Merge pull request #177 from RFlipper/ServerTimeout
Browse files Browse the repository at this point in the history
Ability to setup ServerTimeout for GetResponse.
  • Loading branch information
andyedinborough committed Mar 4, 2015
2 parents e70feb4 + d16a9e6 commit 6bb8650
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 0 additions & 3 deletions ImapClient.cs
Expand Up @@ -28,7 +28,6 @@ public class ImapClient : TextClient, IMailClient {
private string _FetchHeaders = null;

public ImapClient() {
ServerTimeout = 10000;
IdleTimeout = 1200000;
}
public ImapClient(string host, string username, string password, AuthMethods method = AuthMethods.Login, int port = 143, bool secure = false, bool skipSslValidation = false)
Expand All @@ -38,8 +37,6 @@ public ImapClient(string host, string username, string password, AuthMethods met
Login(username, password);
}

public int ServerTimeout { get; set; }

public int IdleTimeout { get; set; }

public virtual AuthMethods AuthMethod { get; set; }
Expand Down
11 changes: 9 additions & 2 deletions TextClient.cs
Expand Up @@ -14,6 +14,7 @@ public abstract class TextClient : IDisposable {
public virtual bool IsAuthenticated { get; private set; }
public virtual bool IsDisposed { get; private set; }
public virtual System.Text.Encoding Encoding { get; set; }
public int ServerTimeout { get; set; }

public event EventHandler<WarningEventArgs> Warning;

Expand All @@ -26,6 +27,7 @@ public abstract class TextClient : IDisposable {

public TextClient() {
Encoding = System.Text.Encoding.GetEncoding(1252);
ServerTimeout = 10000;
}

internal abstract void OnLogin(string username, string password);
Expand Down Expand Up @@ -105,9 +107,14 @@ public abstract class TextClient : IDisposable {
return GetResponse();
}

protected virtual string GetResponse(int Timeout = 10000) {
protected virtual string GetResponse()
{
return GetResponse(ServerTimeout);
}

protected virtual string GetResponse(int timeout) {
int max = 0;
return _Stream.ReadLine(ref max, Encoding, null, Timeout);
return _Stream.ReadLine(ref max, Encoding, null, timeout);
}

protected virtual void SendCommandCheckOK(string command) {
Expand Down

0 comments on commit 6bb8650

Please sign in to comment.