Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- key gConcurrencyRequest = NULL_KEY; // handle for http request
- string gStatsPage = "http://secondlife.com/httprequest/homepage.php";
- integer gPeakConcurrency = 0; // highest count we've seen since reset
- default
- {
- state_entry() {
- // Concurrency is updated every 3 minutes, so there's no urge to check
- // more often.
- llSetTimerEvent(180.);
- // Go get fresh stats from the web
- gConcurrencyRequest = llHTTPRequest(gStatsPage, [], "");
- }
- timer() {
- // Go get fresh stats from the web
- gConcurrencyRequest = llHTTPRequest(gStatsPage, [], "");
- }
- http_response(key request_id, integer status, list metadata, string body) {
- if (request_id == gConcurrencyRequest) {
- // If the web server is acting up, silently give up.
- if (status != 200) {
- return;
- }
- list stats = llParseString2List(body, ["\n"], []);
- integer inworldIndex = llListFindList(stats, ["inworld"]);
- // page format seems to be be broken, silently give up.
- if (inworldIndex == -1) {
- return;
- }
- integer concurrency = (integer) llList2String(stats, inworldIndex + 1);
- // update high mark
- if (gPeakConcurrency < concurrency) {
- gPeakConcurrency = concurrency;
- }
- // update the prim text with the last concurrency seen
- llSetText(
- "Online now: " + (string)concurrency
- + "\nMost seen: " + (string)gPeakConcurrency,
- <1.0, 1.0, 1.0>,
- 1.0
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement