[Xmpp4js-commit] SF.net SVN: xmpp4js: [720] trunk/src/main/javascript/transport
Status: Beta
Brought to you by:
h-iverson
From: <h-i...@us...> - 2008-07-05 05:06:39
|
Revision: 720 http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=720&view=rev Author: h-iverson Date: 2008-07-04 22:06:47 -0700 (Fri, 04 Jul 2008) Log Message: ----------- renamed script.js.js to script.js.... Added Paths: ----------- trunk/src/main/javascript/transport/Script.js Removed Paths: ------------- trunk/src/main/javascript/transport/Script.js.js Copied: trunk/src/main/javascript/transport/Script.js (from rev 719, trunk/src/main/javascript/transport/Script.js.js) =================================================================== --- trunk/src/main/javascript/transport/Script.js (rev 0) +++ trunk/src/main/javascript/transport/Script.js 2008-07-05 05:06:47 UTC (rev 720) @@ -0,0 +1,98 @@ +Ext.namespace( "Xmpp4Js.Transport" ); + +/** + * Functionality that needs testing: + * write: + * sid + * no sid on first request + * always present after session has started + * rid + * always present + * starts random + * sequential + * rollover at int limit + * key + * present / not present if it should be + * first, middle, last, first (init with length 3) + * + * beginSession: + * rid, no sid, correct attributes + * error if called when open + * event is raised + * + * endSession: + * terminate type and correct attributes are present + * error if called while not open + * event is raised + * + * send: + * error before beginSession or after endSession + * multible nodes are combined to make one request + * number of open requests > max open requets + * + * polling: + * doesn't send if there is an open request + * doesn't send if there are items in the queue + * sends empty body if both are empty + */ +Xmpp4Js.Transport.Script = function(config) { + + /** + * @private + * @type String + */ + this.endpoint = config.endpoint; + + var superConfig = config; + + Xmpp4Js.Transport.Script.superclass.constructor.call( this, config ); +} + +Xmpp4Js.Transport.Script.prototype = { + + /** + * Immediately write a raw packet node to the wire. Adds frame data including + * RID, SID and Key if they are present. + * + * Also increments the openRequestCount, which is then decremented in the + * onWriteResponse method. + * + * A possible addition could be to add a "no headers" flag. + * + * @param {DomElement} packetNode + */ + write: function(packetNode) { + + this.prepareWrite( packetNode ); + + // TODO check for max length constraints in browsers + var requestUrl = this.endpoint+"?body="+xml; + var scriptElem = document.createElement( "script" ); + scriptElem.setAttribute( "type", "text/javascript" ); + scriptElem.setAttribute( "src", requestUrl ); + + // TODO handle multiple connections... + window._BOSH_ = function(xml) { + this.handleResponse(); + }.bind(this); + + document.body.appendChild( scriptElem ); + }, + + /** + * Handles the response to a write call. + * + * Decrements the openRequestCount that was incremented in write. + * @private + */ + onWriteResponse: function( xml ) { + this.openRequestCount--; + + // TODO character replacement (18.3)? + + var packetNode = new DOMImplementation().loadXML( xml ).documentElement; + this.fireEvent( "recv", packetNode ); + } +} + +Ext.extend( Xmpp4Js.Transport.Script, Xmpp4Js.Transport.Base, Xmpp4Js.Transport.Script.prototype ); Deleted: trunk/src/main/javascript/transport/Script.js.js =================================================================== --- trunk/src/main/javascript/transport/Script.js.js 2008-07-05 05:05:59 UTC (rev 719) +++ trunk/src/main/javascript/transport/Script.js.js 2008-07-05 05:06:47 UTC (rev 720) @@ -1,98 +0,0 @@ -Ext.namespace( "Xmpp4Js.Transport" ); - -/** - * Functionality that needs testing: - * write: - * sid - * no sid on first request - * always present after session has started - * rid - * always present - * starts random - * sequential - * rollover at int limit - * key - * present / not present if it should be - * first, middle, last, first (init with length 3) - * - * beginSession: - * rid, no sid, correct attributes - * error if called when open - * event is raised - * - * endSession: - * terminate type and correct attributes are present - * error if called while not open - * event is raised - * - * send: - * error before beginSession or after endSession - * multible nodes are combined to make one request - * number of open requests > max open requets - * - * polling: - * doesn't send if there is an open request - * doesn't send if there are items in the queue - * sends empty body if both are empty - */ -Xmpp4Js.Transport.Script = function(config) { - - /** - * @private - * @type String - */ - this.endpoint = config.endpoint; - - var superConfig = config; - - Xmpp4Js.Transport.Script.superclass.constructor.call( this, config ); -} - -Xmpp4Js.Transport.Script.prototype = { - - /** - * Immediately write a raw packet node to the wire. Adds frame data including - * RID, SID and Key if they are present. - * - * Also increments the openRequestCount, which is then decremented in the - * onWriteResponse method. - * - * A possible addition could be to add a "no headers" flag. - * - * @param {DomElement} packetNode - */ - write: function(packetNode) { - - this.prepareWrite( packetNode ); - - // TODO check for max length constraints in browsers - var requestUrl = this.endpoint+"?body="+xml; - var scriptElem = document.createElement( "script" ); - scriptElem.setAttribute( "type", "text/javascript" ); - scriptElem.setAttribute( "src", requestUrl ); - - // TODO handle multiple connections... - window._BOSH_ = function(xml) { - this.handleResponse(); - }.bind(this); - - document.body.appendChild( scriptElem ); - }, - - /** - * Handles the response to a write call. - * - * Decrements the openRequestCount that was incremented in write. - * @private - */ - onWriteResponse: function( xml ) { - this.openRequestCount--; - - // TODO character replacement (18.3)? - - var packetNode = new DOMImplementation().loadXML( xml ).documentElement; - this.fireEvent( "recv", packetNode ); - } -} - -Ext.extend( Xmpp4Js.Transport.Script, Xmpp4Js.Transport.Base, Xmpp4Js.Transport.Script.prototype ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |