improved long polling
This commit is contained in:
parent
a8011462f3
commit
404971ce76
|
@ -228,6 +228,12 @@ public class TelegramAPI implements Runnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
|
if(longpolling) {
|
||||||
|
while(run) {
|
||||||
|
fetchUpdates();
|
||||||
|
fetchedUpdates++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while(run) {
|
while(run) {
|
||||||
long runstart = System.currentTimeMillis();
|
long runstart = System.currentTimeMillis();
|
||||||
fetchUpdates();
|
fetchUpdates();
|
||||||
|
@ -241,6 +247,7 @@ public class TelegramAPI implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isRunning() {
|
public boolean isRunning() {
|
||||||
return thread.isAlive();
|
return thread.isAlive();
|
||||||
|
@ -248,7 +255,7 @@ public class TelegramAPI implements Runnable {
|
||||||
|
|
||||||
private void fetchUpdates() {
|
private void fetchUpdates() {
|
||||||
try {
|
try {
|
||||||
processUpdates(request("getUpdates", "offset=" + msg_offset + "&timeout=" + (longpolling ? updateInterval : 1), true));
|
processUpdates(request("getUpdates", "offset=" + msg_offset + "&timeout=" + (longpolling ? updateInterval : 1), false));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.log("error getting updates.", e);
|
log.log("error getting updates.", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue