Difference between revisions of "Peer-socket.as"
m |
m |
||
| Line 6: | Line 6: | ||
if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) msg( 'connecting...', '00ff00', true ); | if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) msg( 'connecting...', '00ff00', true ); | ||
else msg( 'connect failed!', 'ff0000', true ); | else msg( 'connect failed!', 'ff0000', true ); | ||
| + | |||
| + | msg( 'dsafsafsafa', 'ffff00', true ); | ||
// When connected, send login info | // When connected, send login info | ||
Revision as of 07:51, 26 March 2006
// Establish a connection with Gir (wikid.pl) // - Gir will spawn a dedicated peerd child in response to a valid connection request socket = new XMLSocket();
// Connect to our host to establish stream if ( socket.connect( 'organicdesign.co.nz', 1729 ) ) msg( 'connecting...', '00ff00', true ); else msg( 'connect failed!', 'ff0000', true );
msg( 'dsafsafsafa', 'ffff00', true );
// When connected, send login info socket.onConnect = function( success ) { if ( success ) { msg( 'onConnect succeeded!', '00ff00', true ); sendMessage( 'Hello?' ); } else msg( 'onConnect failed!', 'ff0000', true ); };
// Decode incoming message socket.onData = function( data ) { msg( data, '0000ff', true ); };
// Send a message to the associated peer function sendMessage( content ) { _root.socket.send( content + String.fromCharCode(13,10,13,10) + content + String.fromCharCode(13,10) ); }
function msg( txt, col, app ) { txt = ''+txt+''; //if ( app ) txt = _root.page.htmlText + "\n" + txt; _root.page.htmlText = 'txt'; }



