BastliBridge

A bot framework bridgin multiple IM protocols, and mail
git clone git://xatko.vsos.ethz.ch/BastliBridge.git
Log | Files | Refs | Submodules

commit 9f73336b92499de413db1065152e75348f491fcc
parent 0470aa8af0d96b1960cddad2c6830d97b2bd4464
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Wed, 13 Sep 2017 18:32:14 +0200

Assume that the longpoll-socket can also die at any moment, and recover if it does

Diffstat:
src/telegram.d | 12++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/src/telegram.d b/src/telegram.d @@ -259,15 +259,11 @@ struct Telegram{ void delegate(JSONValue jv)[] onMessage; bool read(){ - auto buf=cast(const(char)[])receive(); - if(buf.length==0){ - return true; + auto updates=response(sock); + if(updates.isNull){ + reconnectSocket(sock); + return false; } - - HTTP response=HTTP.parse(buf); - response.checkCode(); - - auto updates=response.getJSON(); foreach(size_t i, update; updates){ lastUpdate=max(lastUpdate, update["update_id"].integer); writeln(lastUpdate);