Warning: session_start(): open(/var/lib/php/sessions/sess_bf77nrten8fag3a0rpmrnfa83a, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass WebBotTester implements AutoCloseable {
S botURL; // without the "/incremental"
S cookie = "test_" + aGlobalID();
int n; // number of messages grabbed
Thread grabThread;
volatile bool closed;
LS allHtml = syncList();
new L msgs;
double readTimeout = 120.0, sendTimeout = 20.0;
SS extraParams = new LinkedHashMap;
sclass Msg {
S html;
bool fromUser;
long timeReceived;
}
*(S botID) { botURL = "https://botcompany.de/" + psI(botID) + "/raw"; }
public void close {
set closed;
cancelAndInterruptThread(grabThread);
}
selfType start() {
if (grabThread == null)
grabThread = startThread(r _grabLoop);
this;
}
void _grabLoop {
while (!closed) {
S html = loadPageWithTimeout(botURL + "/incremental" + hquery(mapPlus(extraParams, +cookie, a := n)), readTimeout);
allHtml.add(html);
printWithIndent("> ", html);
S comment = first(getHTMLComments(html));
int n = parseFirstIntOrMinus1(comment);
if (n >= 0) this.n = n;
sleepSeconds(1);
}
}
void sendMsg(S message) {
print(postPageWithTimeout(sendTimeout, botURL + "/msg", mapPlus(extraParams, +cookie, +message)));
}
}