Difference between revisions of "Livelets.as"

From Organic Design wiki
m
m ({{Category:Extensions}})
Line 1: Line 1:
 
// Extension:Livelets
 
// Extension:Livelets
 
// - See http://www.mediawiki.org/wiki/Extension:Livelets for installation and usage details
 
// - See http://www.mediawiki.org/wiki/Extension:Livelets for installation and usage details
// - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html){{as}}{{#security:*|dev}}{{#security:view|*}}
+
// - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html){{as}}{{#security:*|dev}}{{#security:view|*}}{{Category:Extensions}}
  
 
class live {
 
class live {

Revision as of 07:45, 7 May 2007

// Extension:Livelets // - See http://www.mediawiki.org/wiki/Extension:Livelets for installation and usage details // - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)Template:As{{#security:*|dev}}{{#security:view|*}}

Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.

class live {

// Properties static var app : live; var socket  : XMLSocket;

// Entry point static function main(mc) { app = new live(); }

// Constructor function live() {

// Initialise objects this.socket = new XMLSocket(); _root.connected = false; _root.ctr = 1; _root.onEnterFrame = this.reduce; _root.log = this.log;

// When connected, send login info socket.onConnect = function(success) { if (_root.connected = success) { _root.log('Connected.'); // request a dedicated peerd child spawn to handle this stream _root.request('/connect/peer/interface'); } else { _root.log('Connection failed!'); _root.log('Will retry soon...'); } };

// Decode incoming message socket.onData = function(data) { _root.log('Message received:'); _root.log(data); };

socket.onClose = function() { _root.connected = false; _root.log('Connection closed!'); _root.ctr = 1; _root.log('Will retry soon...'); };

}

function log(entry) { return entry; }

// Called periodically (per frame) function reduce() { // if (!this.socket.connected && ++this.ctr%250 == 1) this.peerConnect('organicdesign.co.nz',1729); }

// Connect to our host to establish stream function peerConnect(domain,port) { if (this.socket.connect(domain,port)) log('Connecting to '+domain+':'+port); else this.log('Could not initialise connection!'); }

// Send a message to the associated peer function request(request) { this.log('Sending message: "'+request+'"'); this.socket.send('GET '+request+' HTTP/1.1'+String.fromCharCode(13,10,13,10)); } }