Difference between revisions of "Server-monitor.as"

From Organic Design wiki
(test without socket)
(just socket stuff)
Line 1: Line 1:
 
#include "bar-graph.as"
 
#include "bar-graph.as"
 +
 +
echo( 'Begin: Hello world!', 'ff0000' );
  
 
// Establish a connection with perl server
 
// Establish a connection with perl server
Line 5: Line 7:
  
  
createSymbol( this, 'barGraph', 'myGraph', 0 );
+
//createSymbol( this, 'barGraph', 'myGraph', 0 );
  
 
// Connect to our host to establish stream
 
// Connect to our host to establish stream
//if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) echo( 'Connecting...', '00ff00' );
+
if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) echo( 'Connecting...', '00ff00' );
//else echo( 'Could not initialise connection!', 'ff0000' );
+
else echo( 'Could not initialise connection!', 'ff0000' );
  
 
// When connected, send login info
 
// When connected, send login info
Line 38: Line 40:
  
  
function reduce() {
+
//function reduce() {
    myGraph.rotate( Math.sin( ++x/10 ) * height / 3 + height / 2 );
+
//    myGraph.rotate( Math.sin( ++x/10 ) * height / 3 + height / 2 );
    }
+
//    }

Revision as of 04:58, 27 March 2006

  1. include "bar-graph.as"

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

// Establish a connection with perl server socket = new XMLSocket();


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

// Connect to our host to establish stream if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) 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' );
   };

// 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) );
   }

function echo( txt, col ) {

   txt = _root.page.htmlText + "\n" + ''+txt+'';
   _root.page.htmlText = txt;


//function reduce() { // myGraph.rotate( Math.sin( ++x/10 ) * height / 3 + height / 2 ); // }