Warning: session_start(): open(/var/lib/php/sessions/sess_bcl8s355ljamvjtuc33uao9k9t, 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
!7
sclass AllOnlineComputers extends DynCalculatedList {
L data;
transient DialogIO io;
L calc() { ret data; }
void cleanMeUp {
if (io != null) io.close();
}
start {
connect();
doEvery(30000, r { if (io != null) io.sendLine("") });
}
void connect {
thread "Connect" {
while licensed {
try {
io = talkTo("smartbot.botcompany.de", 6000);
io.getSocket().setSoTimeout(30000+10000);
print("Connected.");
temp tempAfterwards(r { print("Disconnected.") });
io.sendLine(format("computerID=*", computerID()));
io.sendLine(format("sub *", "computerIDs"));
print("Sent computer ID: " + computerID());
S line;
while ((line = io.readLine()) != null) {
if (nempty(line)) print("Have msg: " + line);
new Matches m;
if (swic(line, "ComputerIDs = ", m)) {
LS rawData = safeUnstruct($1);
fO computerNames = dm_computerNames_opt();
//setField(data := computerIDs_markMyself(rawData));
setField(data := sortedIC(map(rawData, func(S id) -> S {
S name = dm_callOpt(computerNames, 'nameForID, id);
ret (eq(id, computerID()) ? "[me] " : "")
+ (nempty(name) ? name + " (" + id + ")" : id);
})));
vmBus_send('onlineComputerIDs, rawData);
}
}
} catch e { // pcall would also do an annoying message box
printShortException(e);
}
io = null;
sleepSeconds(5);
}
}
}
// API
LS onlineComputerIDs() { ret data; }
}