Warning: session_start(): open(/var/lib/php/sessions/sess_h5ehvfnku45rcumqg6b0fqd9b2, 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 ConnectedInstances {
ExpiringMap2 recentlyConnected_internal = new ExpiringMap2(5000, r updateValue);
new MultiSet activeConnections;
Map recentlyConnected = synchroMap(recentlyConnected_internal);
SimpleLiveValue connected2 = new(Int, 0); // filtered count
*() {
// TODO (maybe): add countdown to ExpiringMap instead
doEvery(1000, r {
synchronized(recentlyConnected) {
recentlyConnected_internal.clean();
}
});
}
void updateValue {
Set set1 = keys(activeConnections);
Set set2 = keys(recentlyConnected);
int n = l(mergeSets(set1, set2));
connected2.set(n);
print("Updated value to " + n + " (" + l(set1) + "/" + l(set2) + ")");
}
void gotConnection(S computerID) {
if (computerID != null) {
activeConnections.add(computerID);
print("Have active connections from " + computerID + ": " + activeConnections.get(computerID));
updateValue();
}
}
void lostConnection(S computerID) {
if (computerID != null) {
activeConnections.remove(computerID);
print("Disconnected. Have active connections from " + computerID + ": " + activeConnections.get(computerID));
recentlyConnected.put(computerID, true);
updateValue();
}
}
int value() { ret connected2!; }
/*void waitForChange(int value, int timeout) {
waitForVarToChange_withTimeout(connected2, value, timeout);
}*/
}