Difference between revisions of "Server-monitor.as"
From Organic Design wiki
(change domain) |
(graph data from messages) |
||
Line 22: | Line 22: | ||
echo( 'Message received:', '00ff00' ); | echo( 'Message received:', '00ff00' ); | ||
echo( data, 'ffff00' ); | echo( data, 'ffff00' ); | ||
+ | _root.value += data; | ||
}; | }; | ||
Line 35: | Line 36: | ||
function reduce() { | function reduce() { | ||
− | myGraph.rotate( | + | // graph the value and reset the accumulator |
+ | myGraph.rotate( _root.value ); | ||
+ | _root.value = 0; | ||
} | } |
Revision as of 06:21, 27 March 2006
- include "debug.as"
echo( 'Begin: Hello world!', 'ff0000' );
socket = new XMLSocket();
// Connect to our host to establish stream if ( socket.connect( 'www3.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) ); }
- 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; }