Merge pull request #804 from Chase22/configure-longpolling
Add timeout and limit for long-polling updates to DefaultBotOptions
This commit is contained in:
commit
02674a2a39
@ -26,6 +26,8 @@ public class DefaultBotOptions implements BotOptions {
|
||||
private ProxyType proxyType;
|
||||
private String proxyHost;
|
||||
private int proxyPort;
|
||||
private int getUpdatesTimeout;
|
||||
private int getUpdatesLimit;
|
||||
|
||||
public enum ProxyType {
|
||||
NO_PROXY,
|
||||
@ -39,6 +41,8 @@ public class DefaultBotOptions implements BotOptions {
|
||||
baseUrl = ApiConstants.BASE_URL;
|
||||
httpContext = HttpClientContext.create();
|
||||
proxyType = ProxyType.NO_PROXY;
|
||||
getUpdatesLimit = ApiConstants.GETUPDATES_TIMEOUT;
|
||||
getUpdatesLimit = 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,4 +133,20 @@ public class DefaultBotOptions implements BotOptions {
|
||||
public void setProxyPort(int proxyPort) {
|
||||
this.proxyPort = proxyPort;
|
||||
}
|
||||
|
||||
public int getGetUpdatesTimeout() {
|
||||
return getUpdatesTimeout;
|
||||
}
|
||||
|
||||
public void setGetUpdatesTimeout(int getUpdatesTimeout) {
|
||||
this.getUpdatesTimeout = getUpdatesTimeout;
|
||||
}
|
||||
|
||||
public int getGetUpdatesLimit() {
|
||||
return getUpdatesLimit;
|
||||
}
|
||||
|
||||
public void setGetUpdatesLimit(int getUpdatesLimit) {
|
||||
this.getUpdatesLimit = getUpdatesLimit;
|
||||
}
|
||||
}
|
||||
|
@ -236,8 +236,8 @@ public class DefaultBotSession implements BotSession {
|
||||
|
||||
private List<Update> getUpdatesFromServer() throws IOException {
|
||||
GetUpdates request = new GetUpdates()
|
||||
.setLimit(100)
|
||||
.setTimeout(ApiConstants.GETUPDATES_TIMEOUT)
|
||||
.setLimit(options.getGetUpdatesLimit())
|
||||
.setTimeout(options.getGetUpdatesTimeout())
|
||||
.setOffset(lastReceivedUpdate + 1);
|
||||
|
||||
if (options.getAllowedUpdates() != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user