Difference between revisions of "Server-monitor.as"

From Organic Design wiki
(paste logo code)
({{as}})
 
(65 intermediate revisions by 2 users not shown)
Line 1: Line 1:
textcol = '#' + textcol;
+
// Server monitor{{as}}
background = parseInt( background, 16 );
+
#include "debug.as"
bg_r = ( background & 0xff0000 ) >> 16;
+
bg_g = ( background & 0x00ff00 ) >> 8;
+
echo( 'Begin: Hello world!', 'ff0000' );
bg_b = ( background & 0x0000ff );
 
fw = 20; // width of fades
 
id0 = 1;
 
changes = [];
 
change = false;
 
nchanges = 10;
 
offset = -200;
 
  
// Set up async connection with server
+
socket = new XMLSocket();
server = new LoadVars();
+
var value = 0;
server.title = 'RC-Summary'; // wiki page to request
 
server.onLoad = function(success) {
 
if (success) {
 
for ( i = 0; i < nchanges; i++ ) {
 
row = this['item'+i].split(',');
 
id = row.shift();
 
if ( ( i == 0 ) && ( id != id0 ) ) {
 
if ( id0 ) offset = -20;
 
id0 = id;
 
}
 
time = row.shift();
 
user = row.shift();
 
user = '<u><a href="/User:'+user+'">'+user+'</a></u>';
 
title = row.shift();
 
title = '<a href="/'+title+'">'+title+'</a>';
 
comment = row.join(',');
 
if (comment != '') title = comment;
 
changes[i] = '<font face="arial, helvetica" color="'+textcol+'"><i><b>'+user+' &nbsp;</b> ';
 
changes[i] += title+'</i></font><font face="arial" size="17">&nbsp;</font><br>';
 
}
 
rc.htmlText = changes.join('');
 
}
 
};
 
  
// Textbox
+
// Connect to our host to establish stream
createTextField( 'rc', 1, 0, 0, 190, 200 );
+
if ( socket.connect( 'monitor.cs.auckland.ac.nz', 60180 ) ) echo( 'Connecting...', '00ff00' );
with (rc) {
+
else echo( 'Could not initialise connection!', 'ff0000' );
selectable = false;
 
_quality = 'BEST';
 
border = false;
 
multiline = true;
 
wordWrap = false;
 
html = true;
 
}
 
  
// Top fade
+
// When connected, send login info
attachMovie( 'linear', 'top', 2 );
+
socket.onConnect = function( success ) {
col = new Color( top );
+
    if ( success ) {
col.setTransform( { rb:bg_r, gb:bg_g, bb:bg_b } );
+
        echo( 'Connected!', '00ff00' );
top._width = fw;
+
        sendMessage( 'Hello?' );
top._height = width;
+
        }
top._x = width / 2;
+
    else echo( 'Connection failed!', 'ff0000' );
top._y = fw / 2;
+
    };
top._rotation = 90;
 
  
// Bottom fade
+
// Decode incoming message
attachMovie( 'linear', 'bot', 3 );
+
socket.onData = function( data ) {
col = new Color( bot );
+
    echo( 'Message received:', '00ff00' );
col.setTransform( { rb:bg_r, gb:bg_g, bb:bg_b } );
+
    echo( data, 'ffff00' );
bot._width = fw;
+
    _root.value += data;
bot._height = width;
+
    };
bot._x = width / 2;
 
bot._y = height - fw / 2;
 
bot._rotation = 270;
 
  
// Right fade
+
// Send a message to the associated peer
attachMovie( 'linear', 'right', 4 );
+
function sendMessage( content ) {
col = new Color( right );
+
    echo( 'Sending message: "'+content+'"', '00ff00' );
col.setTransform( { rb:bg_r, gb:bg_g, bb:bg_b } );
+
    _root.socket.send( content + String.fromCharCode(13,10,13,10) );
right._width = fw;
+
    }
right._height = height;
 
right._x = width - fw / 2;
 
right._y = height / 2;
 
right._rotation = 180;
 
  
// Logo
+
#include "bar-graph.as"
attachMovie( 'xmlwiki', 'xmlwiki', 5 );
+
 
 +
createSymbol( this, 'barGraph', 'myGraph', 0 );
  
// Per-frame function
 
 
function reduce() {
 
function reduce() {
 
+
    // graph the value and reset the accumulator
// Scrolling
+
    myGraph.rotate( _root.value );
if ( offset < 0 ) offset++;
+
    _root.value = 0;
rc._y = offset;
+
    }
 
 
// Make request on some regular cycle which seems about right
 
if ( ++_root.ctr%400 == 1 ) {
 
server.SWF = id0;
 
server.sendAndLoad( '/wiki/index.php', server, 'GET' );
 
}
 
 
 
}
 

Latest revision as of 09:49, 14 March 2009

// Server monitorTemplate:As

  1. include "debug.as"

echo( 'Begin: Hello world!', 'ff0000' );

socket = new XMLSocket(); var value = 0;

// Connect to our host to establish stream if ( socket.connect( 'monitor.cs.auckland.ac.nz', 60180 ) ) echo( 'Connecting...', '00ff00' ); else echo( 'Could not initialise connection!', 'ff0000' );

// When connected, send login info socket.onConnect = function( success ) {

   if ( success ) {
       echo( 'Connected!', '00ff00' );
       sendMessage( 'Hello?' );
       }
   else echo( 'Connection failed!', 'ff0000' );
   };

// Decode incoming message socket.onData = function( data ) {

   echo( 'Message received:', '00ff00' );
   echo( data, 'ffff00' );
   _root.value += data;
   };

// Send a message to the associated peer function sendMessage( content ) {

   echo( 'Sending message: "'+content+'"', '00ff00' );
   _root.socket.send( content + String.fromCharCode(13,10,13,10) );
   }
  1. include "bar-graph.as"

createSymbol( this, 'barGraph', 'myGraph', 0 );

function reduce() {

   // graph the value and reset the accumulator
   myGraph.rotate( _root.value );
   _root.value = 0;
   }