Skip to content

Commit a12c462

Browse files
committed
Making timeout configurable
1 parent 89beefd commit a12c462

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/UniversalTelegramBot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ String UniversalTelegramBot::sendGetToTelegram(String command) {
6262
client->println("GET /"+command);
6363
now=millis();
6464
avail=false;
65-
while (millis() - now < longPoll * 1000 + 1500) {
65+
while (millis() - now < longPoll * 1000 + waitForResponse) {
6666
while (client->available()) {
6767
char c = client->read();
6868
//Serial.write(c);
@@ -125,7 +125,7 @@ String UniversalTelegramBot::sendPostToTelegram(String command, JsonObject& payl
125125
responseReceived=false;
126126
bool finishedHeaders = false;
127127
bool currentLineIsBlank = true;
128-
while (millis()-now<1500) {
128+
while (millis() - now < waitForResponse) {
129129
while (client->available()) {
130130
char c = client->read();
131131
responseReceived=true;
@@ -255,7 +255,7 @@ String UniversalTelegramBot::sendMultipartFormDataToTelegram(String command, Str
255255
now=millis();
256256
bool finishedHeaders = false;
257257
bool currentLineIsBlank = true;
258-
while (millis()-now<1500) {
258+
while (millis() - now < waitForResponse) {
259259
while (client->available()) {
260260
char c = client->read();
261261
responseReceived=true;

src/UniversalTelegramBot.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class UniversalTelegramBot
8787
String userName;
8888
int longPoll = 0;
8989
bool _debug = false;
90+
int waitForResponse = 1500;
9091

9192
private:
9293
//JsonObject * parseUpdates(String response);

0 commit comments

Comments
 (0)