MOO-cows Mailing List Archive
[Prev][Next][Index][Thread]
Re: Idling?
> Is there any way to automatically kick off people who have been idle for more
> than an hour?
First of all, it should be noted that there isn't really any technical reason
for doing this.. Something which many people don't realize is that idle users
really don't put any load at all on a MOO server or much load on the
underlying unix system either, and whether or not they're connected is
therefore fairly irrelevant for performance/lag/DB-size/whatever concerns..
That aside, DU does use a routine I wrote up for this, more than anything else
just to help keep our @who lists clean and full of people who really are
actually present (or semi-present) and haven't just walked off for 3 days and
forgotten they're connected.. The routine we use on DU follows.
This routine is actually more sophisticated than most.. it allows for
flexibility in idle limits by time of day, it warns people in advance before
booting them, supports a custom (explanation) message as part of the warning,
etc.. It doesn't check lag limits or anything as someone proposed, as as I
mentioned above, they're kinda irrelevant anyway.. it could be added fairly
easily if someone wants to do it anyway, I suppose..
Please don't do idle-booting without warning first (as this routine does).. if
nothing else, I personally really can't stand it. (this is actually one of
the main reasons I don't go to BayMOO much.. every time I do and I go work on
another MOO for a bit, *bam* it very rudely just kicks me off without even
asking me if I'm still there.. I know it's just a badly designed bit of code,
and I know it's easy enough just to reconnect, but it still makes me feel
kinda unwelcome anyway.)
Anyway, there are several properties this routine uses.. idle_check_enabled
and idle_check_interval are fairly self explanatory.. idle_limits consists of
a list of entries of the form:
{time-of-day, {warning-limit, boot-limit}} - set limits for time-of-day on
or
{time-of-day, 0} - set no limit for time-of-day on
time-of-day is seconds-since-midnight of the time when the given limit should
begin. warning-limit is the number of seconds idle someone has to be to get a
warning, and boot-limit is how long someone has to be idle to actually get
booted off. Entries should be in increasing order of time-of-day (the routine
just takes the last entry in the list for which time-of-day <= the current
time of day).
idle_warning is text (if any) to be printed as part of the warning, to explain
why the whole thing is doing what it's doing, or whatever..
This routine is set up to apply to everyone except wizards and descendants of
$moo_link (all net-link-objects on DU are descendants of $moo_link).. this is
easy enough to change however you want..
On DU we put a call to $wiz_utils:idle_check in $login:parse_command so it
gets called every time someone connects, to make sure it's always running even
if the task somehow gets zapped..
Anyway, here you go.. have fun (the below settings will boot after an hour,
with a warning after 55 minutes).
-R
@prop $wiz_utils.idle_check_enabled 1
@prop $wiz_utils.idle_check_task 0
@prop $wiz_utils.idle_check_interval 300
@prop $wiz_utils.idle_limits {{0, {3300, 3600}}}
@prop $wiz_utils.idle_warning {}
@verb $wiz_utils:idle_check tnt
@program $wiz_utils:idle_check
if (!this.idle_check_enabled)
return;
endif
if (!$code_utils:task_valid(this.idle_check_task))
fork id (0)
interval = this.idle_check_interval;
warned = {};
while (this.idle_check_enabled)
time = $time_utils:to_seconds(ctime()[12..19]);
best = -1;
limits = {};
for x in (this.idle_limits)
if ((x[1] > best) && (x[1] <= time))
best = x[1];
limits = x[2];
endif
endfor
if (limits)
warning = limits[1];
cutoff = limits[2];
span = cutoff - warning;
warned_players = $list_utils:slice(warned);
for x in (connected_players())
if (x.wizard || $object_utils:isa(x, $moo_link))
elseif ((idle_seconds(x) > warning) && (!(x in warned_players)))
x:notify_lines(this.idle_warning);
x:notify(tostr("You have been idle for longer than ", $time_utils:english_time(warning), ". If you are still idle in ", $time_utils:english_time(span), " you will be disconnected."));
warned = {@warned, {x, time() + span}};
endif
endfor
for x in (warned)
if (x[2] <= time())
if ($object_utils:connected(x[1]) && (idle_seconds(x[1]) >= cutoff))
x[1]:notify(("*** You have been idle for longer than " + $time_utils:english_time(cutoff)) + ". Closing connection ***");
boot_player(x[1]);
endif
warned = setremove(warned, x);
endif
endfor
else
warned = {};
endif
suspend(interval);
endwhile
endfork
this.idle_check_task = id;
endif
.
------------------------------------------------------------------------------
Alex Stewart - riche@crl.com - Richelieu @ Diversity University MOO
http://www.crl.com/~riche/
"Difficult answers lead to intelligent questions."
References:
- Idling?
- From: "James Renken" <renk0006@gold.tc.umn.edu>
Home |
Subject Index |
Thread Index