xmpp4js-commit Mailing List for xmpp4js: javascript xmpp/jabber library (Page 2)
Status: Beta
Brought to you by:
h-iverson
You can subscribe to this list here.
| 2008 |
Jan
|
Feb
(18) |
Mar
(1) |
Apr
|
May
(4) |
Jun
(6) |
Jul
(47) |
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
|---|
|
From: <h-i...@us...> - 2008-07-25 03:14:51
|
Revision: 745
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=745&view=rev
Author: h-iverson
Date: 2008-07-25 03:15:00 +0000 (Fri, 25 Jul 2008)
Log Message:
-----------
added link to simpleclient and demo of chatmanager
Modified Paths:
--------------
trunk/src/site/xdoc/code-samples.xml
Modified: trunk/src/site/xdoc/code-samples.xml
===================================================================
--- trunk/src/site/xdoc/code-samples.xml 2008-07-23 17:54:32 UTC (rev 744)
+++ trunk/src/site/xdoc/code-samples.xml 2008-07-25 03:15:00 UTC (rev 745)
@@ -5,6 +5,14 @@
</properties>
<body>
+
+ <section name="Information">
+ <p>In addition to these snippets, check out the SimpleClient demo in
+ the <a href="https://xmpp4js.svn.sourceforge.net/svnroot/xmpp4js/xmpp4js-launcher/">xmpp4js-launcher</a> project.</p>
+
+
+ </section>
+
<!-- The body of the document contains a number of sections -->
<section name="Core">
@@ -47,6 +55,45 @@
]]></pre>
</subsection>
+<subsection name="Use Chat Manager">
+<pre name="code" class="javascript"><![CDATA[
+var cm = Xmpp4Js.Chat.ChatManager.getInstanceFor( con );
+
+cm.chatManager.setOptions({
+ ignoreThread: true, // useful for legacy networks (AIM)
+ ignoreResource: true
+});
+
+cm.chatManager.on({
+ scope : this,
+ chatStarted : onChatStarted,
+ messageReceived : onChatMessageReceived
+});
+
+function onChatStarted(chat) {
+ alert( "Chat with "+chat.getParticipant()+" started."
+}
+
+function onChatMessageReceived(chat, messagePacket) {
+ alert( "New message from "+messagePacket.getFrom()+": "+messagePacket.getBody();
+}
+
+function sendMessage(to, message) {
+ var chat = null;
+ try {
+ chat = chatManager.findBestChat( to );
+ } catch(e) {
+ chat = chatManager.createChat( to );
+ }
+
+ var messagePacket = new Xmpp4Js.Packet.Message( to, "normal", message );
+ chat.sendMessage( messagePacket );
+}
+
+]]></pre>
+</subsection>
+
+
<subsection name="Pause / Resume a connection">
<pre name="code" class="javascript"><![CDATA[
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-23 17:54:24
|
Revision: 744
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=744&view=rev
Author: h-iverson
Date: 2008-07-23 17:54:32 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
tweaked pause/resume sample to use cookies for state so reload the page works.
Modified Paths:
--------------
trunk/src/site/xdoc/code-samples.xml
Modified: trunk/src/site/xdoc/code-samples.xml
===================================================================
--- trunk/src/site/xdoc/code-samples.xml 2008-07-23 17:12:07 UTC (rev 743)
+++ trunk/src/site/xdoc/code-samples.xml 2008-07-23 17:54:32 UTC (rev 744)
@@ -50,6 +50,10 @@
<subsection name="Pause / Resume a connection">
<pre name="code" class="javascript"><![CDATA[
+// this assumes ExtJs is present for the state manager. what
+// actually needs to happen is an x-domain state manager needs
+// to be implemented so that state can carry across domains.
+
// setup
LOGIN = "test";
PASSWORD = "test";
@@ -57,11 +61,16 @@
BOSH_TRANSPORT = Xmpp4Js.Transport.Script;
BOSH_ENDPOINT = "http://bosh*.soashable.com:7070/http-bind/";
+Ext.state.Manager.setProvider( new Ext.state.CookieProvider() );
+
// 1, 4
sp = new Xmpp4Js.Packet.StanzaProvider();
sp.registerDefaultProviders();
con = new Xmpp4Js.Connection({transport: {clazz: BOSH_TRANSPORT,endpoint:BOSH_ENDPOINT,useKeys:true},stanzaProvider:sp});
-con.on( "pause", function(pauseStruct) { ps = pauseStruct; console.dir( ps ); } );
+con.on( "pause", function(pauseStruct) {
+ console.dir( pauseStruct );
+ Ext.state.Manager.set( "pauseStruct", pauseStruct );
+});
con.on( "resume", function(pauseStruct) {
con.send( new Xmpp4Js.Packet.Message( SEND_MSG_TO, "normal", "yoooo I'm alive" ) );
});
@@ -76,10 +85,11 @@
// 2
con.connect("soashable.com");
-// 3 - pause for up to 120 seconds
+// 3 - pause for up to 120 seconds. at this point you can reload the page.
con.pause( 120 );
// 5 - you should receive an IM
+ps = Ext.state.Manager.get( "pauseStruct" );
con.resume( ps );
]]></pre>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-23 17:12:01
|
Revision: 743
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=743&view=rev
Author: h-iverson
Date: 2008-07-23 17:12:07 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
cleaned up the code a bit, added pause/resume listeners, updated example
Modified Paths:
--------------
trunk/src/main/javascript/XmppConnection.js
trunk/src/main/javascript/transport/Base.js
trunk/src/site/xdoc/code-samples.xml
Modified: trunk/src/main/javascript/XmppConnection.js
===================================================================
--- trunk/src/main/javascript/XmppConnection.js 2008-07-23 16:49:45 UTC (rev 742)
+++ trunk/src/main/javascript/XmppConnection.js 2008-07-23 17:12:07 UTC (rev 743)
@@ -54,7 +54,11 @@
* @param {String} title
* @param {String} message
*/
- error: true
+ error: true,
+
+ pause: true,
+
+ resume: true
});
/**
@@ -107,7 +111,32 @@
termerror: this.onTerminalError,
error: this.onError,
beginsession: this.onBeginSession,
- endsession: this.onEndSession
+ endsession: this.onEndSession,
+ pause: function(pauseStruct) {
+ // serialize our junk (domain is covered by transport)
+ pauseStruct.jid = this.jid;
+
+ // stop doing stuff
+ // will this cause problems collecting any last packet?
+ this.connected = false;
+ this.transport.un("recv", this.onRecv, this );
+
+ this.fireEvent( "pause", pauseStruct );
+ },
+ resume: function(pauseStruct) {
+ // deserialize our junk
+ this.domain = pauseStruct.domain;
+ this.jid = pauseStruct.jid;
+
+ // return to connected state
+ this.connected = true;
+ this.transport.on({
+ scope: this,
+ recv: this.onRecv
+ });
+
+ this.fireEvent( "resume", pauseStruct );
+ }
// recv will be added in beginSession.
}
});
@@ -295,14 +324,6 @@
// serialize transport's junk
var pauseStruct = this.transport.pause(time);
- // serialize our junk (domain is covered by transport)
- pauseStruct.jid = this.jid;
-
- // stop doing stuff
- // will this cause problems collecting any last packet?
- this.connected = false;
- this.transport.un("recv", this.onRecv, this );
-
return pauseStruct;
},
@@ -317,17 +338,6 @@
// deserialize transport's junk
this.transport.resume(pauseStruct);
-
- // deserialize our junk
- this.domain = pauseStruct.domain;
- this.jid = pauseStruct.jid;
-
- // return to connected state
- this.connected = true;
- this.transport.on({
- scope: this,
- recv: this.onRecv
- });
}
}
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-23 16:49:45 UTC (rev 742)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-23 17:12:07 UTC (rev 743)
@@ -201,7 +201,11 @@
* Raised when the session has been closed (voluntarily). Client code
* should remove any recv handlers here (should we forcibly remove all?).
*/
- endsession: true
+ endsession: true,
+
+ pause: true,
+
+ resume: true
});
Xmpp4Js.Transport.Base.superclass.constructor.call( this, superConfig );
@@ -513,6 +517,9 @@
keySeqIdx: this.keySeq._idx
};
+ // give others an opportunity to serialize proprties
+ this.fireEvent( "pause", pauseStruct );
+
return pauseStruct;
},
@@ -535,6 +542,9 @@
this.keySeq._idx = pauseStruct.keySeqIdx;
this.startup();
+
+ // give others an opportunity to deserialize properties
+ this.fireEvent( "resume", pauseStruct );
}
}
Modified: trunk/src/site/xdoc/code-samples.xml
===================================================================
--- trunk/src/site/xdoc/code-samples.xml 2008-07-23 16:49:45 UTC (rev 742)
+++ trunk/src/site/xdoc/code-samples.xml 2008-07-23 17:12:07 UTC (rev 743)
@@ -49,31 +49,38 @@
<subsection name="Pause / Resume a connection">
<pre name="code" class="javascript"><![CDATA[
-// running all content at once will not work. I might update this to add listeners
-// and the like someday. until then, use firebug's console and run these 1-by-1.
-// 1, 6
+// setup
+LOGIN = "test";
+PASSWORD = "test";
+SEND_MSG_TO = "ha...@so...";
+BOSH_TRANSPORT = Xmpp4Js.Transport.Script;
+BOSH_ENDPOINT = "http://bosh*.soashable.com:7070/http-bind/";
+
+// 1, 4
sp = new Xmpp4Js.Packet.StanzaProvider();
sp.registerDefaultProviders();
con = new Xmpp4Js.Connection({transport: {clazz: BOSH_TRANSPORT,endpoint:BOSH_ENDPOINT,useKeys:true},stanzaProvider:sp});
+con.on( "pause", function(pauseStruct) { ps = pauseStruct; console.dir( ps ); } );
+con.on( "resume", function(pauseStruct) {
+ con.send( new Xmpp4Js.Packet.Message( SEND_MSG_TO, "normal", "yoooo I'm alive" ) );
+});
+con.on( "connect", function() {
+ loginFlow = new Xmpp4Js.Workflow.Login({con:con});
+ loginFlow.on("success", function() {
+ con.send( new Xmpp4Js.Packet.Presence() );
+ } );
+ loginFlow.start( "plaintext", LOGIN, PASSWORD );
+});
// 2
con.connect("soashable.com");
-// 3
-loginFlow = new Xmpp4Js.Workflow.Login({con:con});loginFlow.start( "plaintext", "test", "test" );
+// 3 - pause for up to 120 seconds
+con.pause( 120 );
-// 4
-con.send( new Xmpp4Js.Packet.Presence() );
-
-// 5
-ps = con.pause( 120 );
-
-// 7
+// 5 - you should receive an IM
con.resume( ps );
-
-// 8
-con.send( new Xmpp4Js.Packet.Message( "ha...@so...", "normal", "yoooo I'm alive" ) );
]]></pre>
</subsection>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-23 16:49:36
|
Revision: 742
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=742&view=rev
Author: h-iverson
Date: 2008-07-23 16:49:45 +0000 (Wed, 23 Jul 2008)
Log Message:
-----------
commited first stab at pause/resume. it works using the example in doc, but not in soashable itself yet.
the code needs to be cleaned up a ton, but it works.
Modified Paths:
--------------
trunk/src/main/javascript/KeySequence.js
trunk/src/main/javascript/XmppConnection.js
trunk/src/main/javascript/transport/Base.js
trunk/src/site/xdoc/code-samples.xml
Modified: trunk/src/main/javascript/KeySequence.js
===================================================================
--- trunk/src/main/javascript/KeySequence.js 2008-07-21 19:11:43 UTC (rev 741)
+++ trunk/src/main/javascript/KeySequence.js 2008-07-23 16:49:45 UTC (rev 742)
@@ -25,6 +25,10 @@
* @constructor
*/
function KeySequence(length) {
+ this._keys = [];
+ this._idx = null;
+ this._seed = null;
+
this._initKeys( length );
}
Modified: trunk/src/main/javascript/XmppConnection.js
===================================================================
--- trunk/src/main/javascript/XmppConnection.js 2008-07-21 19:11:43 UTC (rev 741)
+++ trunk/src/main/javascript/XmppConnection.js 2008-07-23 16:49:45 UTC (rev 742)
@@ -75,24 +75,20 @@
stanzaProvider: this.stanzaProvider
});
+ this.setupTransport();
+
+
Xmpp4Js.Connection.superclass.constructor.call( this, superConfig );
+ if( config.pauseStruct != undefined ) {
+ this.resume( config.pauseStruct );
+ }
+
}
Xmpp4Js.Connection.prototype = {
- /**
- * Connect to a given domain, port and server. Only domain is required.
- */
- connect: function(domain, port, server) {
- // TODO it would be nice to be able to give a connect
- // event as a parameter, that registers on this and
- // unregisters right after it's called.
- if( this.isConnected() ) {
- throw new Xmpp4Js.Error( "Already Connected" );
- }
- this.domain = domain;
-
+ setupTransport: function(server, port) {
var transportClass = this.transportConfig.clazz;
if( typeof transportClass != 'function' ) {
@@ -117,6 +113,22 @@
});
this.transport = new transportClass(transportConfig);
+ },
+
+ /**
+ * Connect to a given domain, port and server. Only domain is required.
+ */
+ connect: function(domain, server, port) {
+ // TODO it would be nice to be able to give a connect
+ // event as a parameter, that registers on this and
+ // unregisters right after it's called.
+
+ if( this.isConnected() ) {
+ throw new Xmpp4Js.Error( "Already Connected" );
+ }
+ this.domain = domain;
+
+ this.setupTransport( server, port );
this.transport.beginSession();
},
@@ -270,6 +282,52 @@
*/
getJid : function() {
return new Xmpp4Js.Jid(this.jid);
+ },
+
+ /**
+ * Sends a pause command to the server and returns a struct that may be
+ * serialized and passed to resume.
+ * @param {Number} time Time in seconds to allow inactivity. No longer than maxpause.
+ * @public
+ */
+ pause: function(time) {
+
+ // serialize transport's junk
+ var pauseStruct = this.transport.pause(time);
+
+ // serialize our junk (domain is covered by transport)
+ pauseStruct.jid = this.jid;
+
+ // stop doing stuff
+ // will this cause problems collecting any last packet?
+ this.connected = false;
+ this.transport.un("recv", this.onRecv, this );
+
+ return pauseStruct;
+ },
+
+ /**
+ * Sends a pause command to the server and returns a struct that may be
+ * serialized and passed to resume.
+ * @param {Number} time Time in seconds to allow inactivity. No longer than maxpause.
+ * @public
+ */
+ resume: function(pauseStruct) {
+ this.setupTransport( pauseStruct.server, pauseStruct.port );
+
+ // deserialize transport's junk
+ this.transport.resume(pauseStruct);
+
+ // deserialize our junk
+ this.domain = pauseStruct.domain;
+ this.jid = pauseStruct.jid;
+
+ // return to connected state
+ this.connected = true;
+ this.transport.on({
+ scope: this,
+ recv: this.onRecv
+ });
}
}
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-21 19:11:43 UTC (rev 741)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-23 16:49:45 UTC (rev 742)
@@ -477,6 +477,64 @@
*/
createInitialRid: function() {
return Math.floor( Math.random() * 10000 );
+ },
+
+ pause: function(time) {
+ var pauseNode = this.createPacketNode();
+ pauseNode.setAttribute( "pause", time );
+
+ /*
+ * the connection manager SHOULD respond immediately to all pending
+ * requests (including the pause request) and temporarily increase
+ * the maximum inactivity period to the requested time.
+
+ this.on("recv", function(packet) {
+ this.fireEvent( "pause", pauseStruct );
+ }, this, {single:true});
+ */
+
+ this.write( pauseNode );
+
+ this.shutdown();
+
+ var pauseStruct = {
+ maxpause: 120, // TODO not hard code me
+ maxRequests: this.maxRequests,
+ hold: this.hold,
+ polling: this.polling,
+ server: this.server,
+ port: this.port,
+ domain: this.domain,
+ wait: this.wait,
+ sid: this.sid,
+ rid: this.rid,
+ endpoint: this.endpoint, // TODO subclass implementations should handle this
+ keysSeqKeys : this.keySeq._keys,
+ keySeqIdx: this.keySeq._idx
+ };
+
+ return pauseStruct;
+ },
+
+ resume: function(pauseStruct) {
+
+ // this.maxpause = pauseStruct.maxpause;
+ this.maxpause = pauseStruct.maxpause;
+ this.hold = pauseStruct.hold;
+ this.polling = pauseStruct.polling;
+ this.server = pauseStruct.server;
+ this.port = pauseStruct.port;
+ this.wait = pauseStruct.wait;
+ this.sid = pauseStruct.sid;
+ this.rid = pauseStruct.rid;
+ this.domain = pauseStruct.domain;
+ this.endpoint = pauseStruct.endpoint;
+ this.maxRequests = pauseStruct.maxRequests;
+
+ this.keySeq._keys = pauseStruct.keysSeqKeys;
+ this.keySeq._idx = pauseStruct.keySeqIdx;
+
+ this.startup();
}
}
Modified: trunk/src/site/xdoc/code-samples.xml
===================================================================
--- trunk/src/site/xdoc/code-samples.xml 2008-07-21 19:11:43 UTC (rev 741)
+++ trunk/src/site/xdoc/code-samples.xml 2008-07-23 16:49:45 UTC (rev 742)
@@ -47,12 +47,35 @@
]]></pre>
</subsection>
-<subsection name="Suspend a connection">
-<p>... can't do it yet ...</p>
-</subsection>
+<subsection name="Pause / Resume a connection">
+<pre name="code" class="javascript"><![CDATA[
+// running all content at once will not work. I might update this to add listeners
+// and the like someday. until then, use firebug's console and run these 1-by-1.
-<subsection name="Resume a connection">
-<p>... can't do it yet ...</p>
+// 1, 6
+sp = new Xmpp4Js.Packet.StanzaProvider();
+sp.registerDefaultProviders();
+con = new Xmpp4Js.Connection({transport: {clazz: BOSH_TRANSPORT,endpoint:BOSH_ENDPOINT,useKeys:true},stanzaProvider:sp});
+
+// 2
+con.connect("soashable.com");
+
+// 3
+loginFlow = new Xmpp4Js.Workflow.Login({con:con});loginFlow.start( "plaintext", "test", "test" );
+
+// 4
+con.send( new Xmpp4Js.Packet.Presence() );
+
+// 5
+ps = con.pause( 120 );
+
+// 7
+con.resume( ps );
+
+// 8
+con.send( new Xmpp4Js.Packet.Message( "ha...@so...", "normal", "yoooo I'm alive" ) );
+
+]]></pre>
</subsection>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-21 19:11:35
|
Revision: 741
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=741&view=rev
Author: h-iverson
Date: 2008-07-21 19:11:43 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
fixed error in IE
Modified Paths:
--------------
trunk/src/main/javascript/adapter/Default.js
Modified: trunk/src/main/javascript/adapter/Default.js
===================================================================
--- trunk/src/main/javascript/adapter/Default.js 2008-07-16 04:16:48 UTC (rev 740)
+++ trunk/src/main/javascript/adapter/Default.js 2008-07-21 19:11:43 UTC (rev 741)
@@ -211,6 +211,10 @@
* @private
*/
_IEEnumFix: (Xmpp4Js.UA.ie) ? function(r, s) {
+
+ // ADD = ["toString", "valueOf", "hasOwnProperty"],
+ var ADD = ["toString", "valueOf"];
+
for (var i=0;i<ADD.length;i=i+1) {
var fname=ADD[i],f=s[fname];
if (Xmpp4Js.Lang.isFunction(f) && f!=Object.prototype[fname]) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-16 04:16:40
|
Revision: 740
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=740&view=rev
Author: h-iverson
Date: 2008-07-15 21:16:48 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
added wiki link
Modified Paths:
--------------
trunk/src/site/site.xml
Modified: trunk/src/site/site.xml
===================================================================
--- trunk/src/site/site.xml 2008-07-15 19:41:32 UTC (rev 739)
+++ trunk/src/site/site.xml 2008-07-16 04:16:48 UTC (rev 740)
@@ -40,6 +40,7 @@
<item name="Xmpp4Js" href="http://xmpp4js.sourceforge.net"/>
<item name="Live Demo" href="http://www.soashable.com/" />
<item name="Blog" href="http://soashable.blogspot.com/" />
+ <item name="Wiki" href="http://soashable.wiki.sourceforge.net/"/>
</links>
<menu name="About Xmpp4Js">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-15 19:41:26
|
Revision: 739
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=739&view=rev
Author: h-iverson
Date: 2008-07-15 12:41:32 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
made bullets into headers
Modified Paths:
--------------
trunk/src/site/apt/index.apt
Modified: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt 2008-07-15 16:51:05 UTC (rev 738)
+++ trunk/src/site/apt/index.apt 2008-07-15 19:41:32 UTC (rev 739)
@@ -6,19 +6,17 @@
07/15/2008
------
-About Xmpp4Js
-
Xmpp4Js is an XMPP client library written in pure Javascript. It connects to a
server using BOSH (XEP-0124, 0206) Binding or Script Syntax.
- * HTTP Binding
+HTTP Binding
This method uses XmlHttpRequests to get and receive packets from a BOSH implementation
on the same domain as the connecting site. The only way to run in BOSH mode
is to serve your site from the same domain as the BOSH implementation (same-origin policy);
this can be achieved by using an HTTP proxy or a Servlet filter.
- * Script Syntax
+Script Syntax
Script Syntax allows connections to a remote BOSH server without requiring a BOSH
implementation on the same domain as your site--it is immune from the same-origin
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-15 16:51:00
|
Revision: 738
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=738&view=rev
Author: h-iverson
Date: 2008-07-15 09:51:05 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
wrote a new description
Modified Paths:
--------------
trunk/src/site/apt/index.apt
Modified: trunk/src/site/apt/index.apt
===================================================================
--- trunk/src/site/apt/index.apt 2008-07-10 21:20:27 UTC (rev 737)
+++ trunk/src/site/apt/index.apt 2008-07-15 16:51:05 UTC (rev 738)
@@ -3,26 +3,28 @@
------
Harlan Iverson
------
- 02/08/2008
+ 07/15/2008
------
About Xmpp4Js
- Xmpp4Js is an XMPP client written in pure Javascript. It connects to a server
- using BOSH (XEP-0124), which is a COMET protocol that provides instantaneous
- responses.
+ Xmpp4Js is an XMPP client library written in pure Javascript. It connects to a
+ server using BOSH (XEP-0124, 0206) Binding or Script Syntax.
- It allows any web page to be active on an XMPP network. Uses can range from
- a simple Meebo-like chat client, to a phpLive-like support interface, and beyond.
+ * HTTP Binding
- Xmpp4Js is supported in all major browsers, which removes compatibility
- limitations inherent in browser extensions like xmpp4moz.
+ This method uses XmlHttpRequests to get and receive packets from a BOSH implementation
+ on the same domain as the connecting site. The only way to run in BOSH mode
+ is to serve your site from the same domain as the BOSH implementation (same-origin policy);
+ this can be achieved by using an HTTP proxy or a Servlet filter.
- The initial release includes a sample chat client with basic in-browser
- messaging functionality, and all dependencies.
+ * Script Syntax
- Xmpp4Js is dual-licensed under LGPL and Apache 2.0.
+ Script Syntax allows connections to a remote BOSH server without requiring a BOSH
+ implementation on the same domain as your site--it is immune from the same-origin
+ policy. This is because it uses script tags rather than XmlHttpRequest.
-* Requirements
+ This method also allows XMPP-enabled applications to be run locally though a
+ plain HTML file or Adobe Air.
- {{{bosh-environment.html}BOSH environment}}
\ No newline at end of file
+ There are no performance reasons or otherwise to avoid using Script Syntax.
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-10 18:12:19
|
Revision: 736
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=736&view=rev
Author: h-iverson
Date: 2008-07-10 11:12:21 -0700 (Thu, 10 Jul 2008)
Log Message:
-----------
use wildcard script endpoint
Modified Paths:
--------------
xmpp4js-launcher/src/main/webapp/simpleclient.html
Modified: xmpp4js-launcher/src/main/webapp/simpleclient.html
===================================================================
--- xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-10 18:11:45 UTC (rev 735)
+++ xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-10 18:12:21 UTC (rev 736)
@@ -21,13 +21,13 @@
<dd><input type="password" name="password"/></dd>
<dt>Transport</dt>
- <dd><select name="transport" onchange="this.form.endpoint.value = (this.value == 'script' ? 'https://bosh.soashable.com:7443/http-bind/' : '/http-bind/');">
+ <dd><select name="transport" onchange="this.form.endpoint.value = (this.value == 'script' ? 'https://*.bosh.soashable.com:7443/http-bind/' : '/http-bind/');">
<option value="script" onclick="">Script (X-Domain)</option>
<option value="bosh">BOSH (Local Servlet)</option>
</select></dd>
<dt>Transport Endpoint</dt>
- <dd><input type="text" name="endpoint" value="https://bosh.soashable.com:7443/http-bind/"/></dd>
+ <dd><input type="text" name="endpoint" value="https://*.bosh.soashable.com:7443/http-bind/"/></dd>
<dt></dt>
<dd><button type="submit">Login</button></dd>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-10 18:11:37
|
Revision: 735
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=735&view=rev
Author: h-iverson
Date: 2008-07-10 11:11:45 -0700 (Thu, 10 Jul 2008)
Log Message:
-----------
made script transport support random wildcard hosts in order to get around browser connection limits. eg. *.bosh.soashable.com becomes 9534.bosh.soashable.com, where 9534 is some random 4 digit number. to use, include a * in the endpoint provided in config.
Modified Paths:
--------------
trunk/src/main/javascript/transport/Script.js
Modified: trunk/src/main/javascript/transport/Script.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js 2008-07-07 22:02:32 UTC (rev 734)
+++ trunk/src/main/javascript/transport/Script.js 2008-07-10 18:11:45 UTC (rev 735)
@@ -37,6 +37,13 @@
*/
Xmpp4Js.Transport.Script = function(config) {
+ // support wild card hosts to get around the 2 connection
+ // limit
+ if( config.endpoint.indexOf('*') > -1 ) {
+ var rand = parseInt(Math.random() * 10000); // 4 digits of random
+ config.endpoint = config.endpoint.replace('*', rand);
+ }
+
/**
* @private
* @type String
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 22:02:56
|
Revision: 734
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=734&view=rev
Author: h-iverson
Date: 2008-07-07 15:02:32 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
finishing touch on removing extjs requirement
Modified Paths:
--------------
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-07-07 21:58:17 UTC (rev 733)
+++ trunk/pom.xml 2008-07-07 22:02:32 UTC (rev 734)
@@ -22,12 +22,6 @@
<version>1.5.1-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>com.extjs</groupId>
- <artifactId>extjs-debug</artifactId>
- <type>javascript</type>
- <version>2.0-SNAPSHOT</version>
- </dependency>
- <dependency>
<groupId>uk.org.pajhome</groupId>
<artifactId>crypto</artifactId>
<type>javascript</type>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 21:58:38
|
Revision: 733
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=733&view=rev
Author: h-iverson
Date: 2008-07-07 14:58:17 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
got rid of all extjs dependence =]
Modified Paths:
--------------
xmpp4js-launcher/src/main/webapp/simpleclient.html
Modified: xmpp4js-launcher/src/main/webapp/simpleclient.html
===================================================================
--- xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-07 21:57:49 UTC (rev 732)
+++ xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-07 21:58:17 UTC (rev 733)
@@ -2,7 +2,6 @@
<head>
<title>Xmpp4Js Sample Client</title>
<script type="text/javascript" src="scripts/lib/prototype.js"> </script>
- <script type="text/javascript" src="scripts/lib/extjs2.js"></script>
<script type="text/javascript" src="scripts/lib/dom-all.js"></script>
<script type="text/javascript" src="scripts/lib/crypto.js"></script>
<script type="text/javascript" src="scripts/lib/xmpp4js.js"></script>
@@ -131,11 +130,8 @@
* Append a message to message-area.
*/
logMessage: function(msg, cssClasses) {
- var msgArea = Ext.get( "message-area" );
-
- this.logMessageTemplate.append( msgArea, {cssClasses: cssClasses, msg: msg} );
-
- msgArea.scroll("down", 5000, true);
+ var msgArea = document.getElementById( "message-area" );
+ msgArea.innerHTML += "<div class='message "+cssClasses+"'>"+msg+"</div>";
},
@@ -267,25 +263,15 @@
}
// else, some extension sending a message.
- },
-
- /**
- * The template to use for log messages.
- * @private
- */
- logMessageTemplate: new Ext.Template( "<div class='message {cssClasses}'>{msg}</div>" )
+ }
}
var client = null;
-Ext.onReady(function() {
+window.onload = function() {
client = new SimpleClient();
-
- if( !Ext.isOpera && !Ext.isGecko && !Ext.isIE7 && !Ext.isSafari ) {
- client.logMessage( "You're using an untested browser. Please let me know how it goes. <a href='mailto:h.i...@gm...'>h.i...@gm...</a>" );
- }
-
+
client.logMessage( "Client ready." );
-});
+};
-->
</script>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 21:58:20
|
Revision: 732
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=732&view=rev
Author: h-iverson
Date: 2008-07-07 14:57:49 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
got rid of all extjs dependence =]
Modified Paths:
--------------
trunk/src/assembler/xmpp4js.xml
Modified: trunk/src/assembler/xmpp4js.xml
===================================================================
--- trunk/src/assembler/xmpp4js.xml 2008-07-07 21:18:33 UTC (rev 731)
+++ trunk/src/assembler/xmpp4js.xml 2008-07-07 21:57:49 UTC (rev 732)
@@ -82,7 +82,8 @@
<include>muc/MucManager.js</include>
<include>muc/ext/**.js</include>
- <include>ext/**.js</include>
+ <include>ext/DataStorage.js</include>
+ <include>ext/ServiceDisco.js</include>
<include>workflow/**.js</include>
</includes>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 21:18:42
|
Revision: 731
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=731&view=rev
Author: h-iverson
Date: 2008-07-07 14:18:33 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
replaced ext TaskRunner with custom, untested impl...woooo
Modified Paths:
--------------
trunk/src/main/javascript/adapter/Default.js
trunk/src/main/javascript/transport/Base.js
Modified: trunk/src/main/javascript/adapter/Default.js
===================================================================
--- trunk/src/main/javascript/adapter/Default.js 2008-07-07 20:45:50 UTC (rev 730)
+++ trunk/src/main/javascript/adapter/Default.js 2008-07-07 21:18:33 UTC (rev 731)
@@ -337,7 +337,7 @@
if (xhr.readyState == 4 ) {
var success = xhr.status == 200;
- request.callback.call( request.scope, request, sucess, xhr );
+ request.callback.call( request.scope, request, success, xhr );
}
};
@@ -397,6 +397,65 @@
}
+Soashable.Lang.TaskRunner = function(interval) {
+ this.interval = interval;
+ this.tasks = [];
+
+ this.intervalId = setInterval(this.onInterval.bind(this), this.interval);
+}
+Soashable.Lang.TaskRunner.prototype = {
+ start: function(task) {
+ this.tasks.push( task );
+ },
+
+ stop: function(task) {
+ var removeIdxs = [];
+
+ for( var i = 0; i < this.tasks.length; i++ ) {
+ if( this.tasks[i] === task ) {
+ removeIdxs.push( i );
+ }
+ }
+
+ this.removeTasks( removeIdxs );
+ },
+
+ removeTasks: function( removeIdxs ) {
+ // JS is single threaded, so this shouldn't have concurrency issues
+ for( var i = 0; i < removeIdxs.length; i++ ) {
+ var task = this.tasks[i];
+
+ // fire a stop event if present
+ if( task.onStop ) {
+ task.onStop.apply( task.scope ? task.scope : task );
+ }
+
+ this.tasks.splice( i, 1 );
+ }
+ },
+
+ stopAll: function() {
+ var removeIdxs = [];
+
+ // this is kind of stupid...
+ for( var i = 0; i < this.tasks.length; i++ ) {
+ removeIdxs.push(i);
+ }
+
+ this.removeTasks( removeIdxs );
+ },
+
+ onInterval: function() {
+ for( var i = 0; i < this.tasks.length; i++ ) {
+ var task = this.tasks[i];
+
+ task.run.apply( task.scope ? task.scope : task );
+ }
+ }
+
+}
+
+
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-07 20:45:50 UTC (rev 730)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-07 21:18:33 UTC (rev 731)
@@ -77,15 +77,14 @@
* @type Ext.util.TaskRunner
* @private
*/
- this.taskRunner = new Ext.util.TaskRunner();
+ this.taskRunner = new Soashable.Lang.TaskRunner(500);
/**
* @private
*/
this.sendQueueTask = {
scope: this,
- run: this.sendQueue,
- interval: 500
+ run: this.sendQueue
};
/**
@@ -93,8 +92,7 @@
*/
this.sendPollTask = {
scope: this,
- run: this.sendPoll,
- interval: 500
+ run: this.sendPoll
};
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 20:45:53
|
Revision: 730
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=730&view=rev
Author: h-iverson
Date: 2008-07-07 13:45:50 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
remove urlEncoder dependence and a couple more Observable references I forgot in test dir
Modified Paths:
--------------
trunk/src/main/javascript/adapter/Default.js
trunk/src/main/javascript/transport/Script.js
trunk/src/test/javascript/common-test-library.js
Modified: trunk/src/main/javascript/adapter/Default.js
===================================================================
--- trunk/src/main/javascript/adapter/Default.js 2008-07-07 20:35:35 UTC (rev 729)
+++ trunk/src/main/javascript/adapter/Default.js 2008-07-07 20:45:50 UTC (rev 730)
@@ -367,6 +367,30 @@
return xhr;
},
+ urlEncode: function (clearString) {
+ var output = '';
+ var x = 0;
+ clearString = clearString.toString();
+ var regex = /(^[a-zA-Z0-9_.]*)/;
+ while (x < clearString.length) {
+ var match = regex.exec(clearString.substr(x));
+ if (match != null && match.length > 1 && match[1] != '') {
+ output += match[1];
+ x += match[1].length;
+ } else {
+ if (clearString[x] == ' ') {
+ output += '+';
+ } else {
+ var charCode = clearString.charCodeAt(x);
+ var hexVal = charCode.toString(16);
+ output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
+ }
+ x++;
+ }
+ }
+ return output;
+ },
+
noOp: function(){}
Modified: trunk/src/main/javascript/transport/Script.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js 2008-07-07 20:35:35 UTC (rev 729)
+++ trunk/src/main/javascript/transport/Script.js 2008-07-07 20:45:50 UTC (rev 730)
@@ -76,7 +76,7 @@
// TODO check for max length constraints in browsers
// HACK substr(5) takes out body=; there should be a method to
// only encode the right-hand side of the params.
- var requestUrl = this.endpoint+"?"+Ext.urlEncode({body: xml}).substr(5);
+ var requestUrl = this.endpoint+"?"+Soashable.Lang.urlEncode(xml);
var scriptElem = document.createElement( "script" );
scriptElem.setAttribute( "type", "text/javascript" );
Modified: trunk/src/test/javascript/common-test-library.js
===================================================================
--- trunk/src/test/javascript/common-test-library.js 2008-07-07 20:35:35 UTC (rev 729)
+++ trunk/src/test/javascript/common-test-library.js 2008-07-07 20:45:50 UTC (rev 730)
@@ -21,7 +21,7 @@
};
};
-Soashable.Lang.extend( MockRequest, Ext.util.Observable, {
+Soashable.Lang.extend( MockRequest, Soashable.Event.EventProvider, {
request: function(options) {
this.fireEvent( "beforerequest", this, options );
@@ -237,7 +237,7 @@
}
}
-Soashable.Lang.extend( TestTransport, Ext.util.Observable, TestTransport.prototype );
+Soashable.Lang.extend( TestTransport, Soashable.Event.EventProvider, TestTransport.prototype );
@@ -322,4 +322,4 @@
}
}
-Soashable.Lang.extend( MockConnection, Ext.util.Observable, MockConnection.prototype );
+Soashable.Lang.extend( MockConnection, Soashable.Event.EventProvider, MockConnection.prototype );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 20:35:41
|
Revision: 729
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=729&view=rev
Author: h-iverson
Date: 2008-07-07 13:35:35 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
removed Ext.data.Connection usage
Modified Paths:
--------------
trunk/src/main/javascript/adapter/Default.js
Modified: trunk/src/main/javascript/adapter/Default.js
===================================================================
--- trunk/src/main/javascript/adapter/Default.js 2008-07-07 19:51:38 UTC (rev 728)
+++ trunk/src/main/javascript/adapter/Default.js 2008-07-07 20:35:35 UTC (rev 729)
@@ -327,28 +327,52 @@
},
asyncRequest: function(request) {
- var con = new Ext.data.Connection({
- url: request.url,
- method: request.method,
-
- timeout: request.timeout,
- disableCaching: request.disableCaching,
- headers: request.headers
- });
-
- var xml = request.xmlNode.toString();
-
- con.request({
- xmlData: xml,
- xmlNode: request.xmlNode, // this is useful for testing
- scope: request.scope,
- callback: request.callback
- });
+ var xhr = Soashable.Lang.createXhr();
+
+ xhr.open(request.method, request.url, true);
+ for( var header in request.headers ) {
+ xhr.setRequestHeader( header, request.headers[ header ] );
+ }
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState == 4 ) {
+ var success = xhr.status == 200;
+
+ request.callback.call( request.scope, request, sucess, xhr );
+ }
+ };
+
+ var xml = request.xmlNode.toString();
+
+ xhr.send(xml);
},
+ createXhr : function () {
+ var xhr = false;
+ if(window.XMLHttpRequest) {
+ xhr = new XMLHttpRequest();
+ if(xhr.overrideMimeType) {
+ xhr.overrideMimeType('text/xml');
+ }
+ } else if(window.ActiveXObject) {
+ try {
+ xhr = new ActiveXObject('Msxml2.XMLHTTP');
+ } catch(e) {
+ try {
+ xhr = new ActiveXObject('Microsoft.XMLHTTP');
+ } catch(e) {
+ xhr = false;
+ }
+ }
+ }
+ return xhr;
+ },
+
noOp: function(){}
}
+
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 18:34:38
|
Revision: 727
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=727&view=rev
Author: h-iverson
Date: 2008-07-07 11:34:42 -0700 (Mon, 07 Jul 2008)
Log Message:
-----------
removed relience on ext.util.observable
Modified Paths:
--------------
trunk/src/main/javascript/BayeuxXmppClient.js
trunk/src/main/javascript/Events.js
trunk/src/main/javascript/JabberClient.js
trunk/src/main/javascript/PluginManager.js
trunk/src/main/javascript/XmppConnection.js
trunk/src/main/javascript/chat/Chat.js
trunk/src/main/javascript/chat/ChatManager.js
trunk/src/main/javascript/ext/ServiceDisco.js
trunk/src/main/javascript/muc/MucManager.js
trunk/src/main/javascript/muc/MucRoom.js
trunk/src/main/javascript/roster/PresenceManager.js
trunk/src/main/javascript/roster/RosterItemManager.js
trunk/src/main/javascript/transport/Base.js
trunk/src/main/javascript/workflow/Login.js
trunk/src/main/javascript/workflow/Registration.js
trunk/src/test/javascript/DelegateManagerTest.html
Added Paths:
-----------
trunk/src/test/javascript/EventProviderTest.html
Modified: trunk/src/main/javascript/BayeuxXmppClient.js
===================================================================
--- trunk/src/main/javascript/BayeuxXmppClient.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/BayeuxXmppClient.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -80,4 +80,4 @@
}
-Ext.extend(Xmpp4Js.BayeuxXmppClient , Ext.util.Observable, Xmpp4Js.BayeuxXmppClient .prototype);
\ No newline at end of file
+Ext.extend(Xmpp4Js.BayeuxXmppClient , Xmpp4Js.Event.EventProvider, Xmpp4Js.BayeuxXmppClient .prototype);
\ No newline at end of file
Modified: trunk/src/main/javascript/Events.js
===================================================================
--- trunk/src/main/javascript/Events.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/Events.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -45,7 +45,8 @@
var fireArgs = arguments;
$H(this.map).each(function(pair) {
try {
- pair.value.apply(pair.value,fireArgs);
+ // scope doesn't matter, should have been set with bind()
+ pair.value.apply(null,fireArgs);
} catch(e) {
// TODO do something
}
@@ -118,4 +119,111 @@
args.shift();
dm.fire.apply( dm, args );
-}
\ No newline at end of file
+}
+
+Ext.namespace( "Xmpp4Js.Event" );
+
+// TODO add test
+Xmpp4Js.Event.EventProvider = function(config) {
+ this.eventListenerManager = new EventListenerManager();
+
+ if( config.listeners ) {
+ this.on( config.listeners );
+ }
+}
+
+Xmpp4Js.Event.EventProvider.prototype = {
+ addEvents: function(events) {
+ // do nothing, just here for compat with Observable
+ if( !this.eventListenerManager ) {
+ this.eventListenerManager = new EventListenerManager();
+ }
+ },
+
+ /**
+ * If doing multiple, should scope and options be passed? doesn't seem likely.
+ */
+ addListener: function(event, listener, scope, options) {
+ if( typeof event == "object" ) {
+ for( var e in event ) {
+ if( e != "scope" && e != "options" ) {
+ this.addListener( e, event[e], event.scope ? event.scope : undefined, event.options ? event.options : undefined );
+ }
+ }
+ return;
+ }
+
+ // if scope is specified, run the listener funciton in that scope
+ if( scope ) {
+ listener = listener.bind(scope);
+ }
+
+ // immediately remove the listener and then call it.
+ if( options && options["single"] == true ) {
+ var eventProvider = this;
+ var originalListener = listener; // prevent recursion
+
+ listener = function() {
+ eventProvider.removeListener( event, arguments.callee ); // remove this
+
+ originalListener.apply(this, arguments); // use current this and arguments
+ }
+ }
+
+
+
+ this.eventListenerManager.add( event, listener );
+ },
+
+ removeListener: function(event, listener) {
+ if( typeof event == "object" ) {
+ for( var e in event ) {
+ this.removeListener( e, event[e] );
+ }
+ }
+
+ // TODO this code could probably be refactored to eventListenerManager
+ var removeId;
+ var delegateMap = this.eventListenerManager.getMap( event );
+ for( var id in delegateMap ) {
+ var delegateListener = delegateMap[id];
+ if( delegateListener === listener ) {
+ removeId = id;
+ }
+ }
+
+ this.eventListenerManager.remove( event, id );
+ },
+
+ fireEvent: function(event, args) {
+ var callArgs = $A(arguments);
+ callArgs.shift(); // pull off the event
+
+ this.eventListenerManager.fireArgs( event, callArgs );
+ },
+
+ hasListener: function() {
+ alert( "hasListener not implemented" );
+ },
+
+ purgeListeners: function() {
+ alert( "hasListener not implemented" );
+ },
+
+ relayEvents: function() {
+ alert( "relayEvents not implemented" );
+ },
+
+ resumeEvents: function() {
+ alert( "resumeEvents not implemented" );
+ },
+
+ suspendEvents: function() {
+ alert( "suspendEvents not implemented" );
+ }
+
+
+}
+
+Xmpp4Js.Event.EventProvider.prototype.on = Xmpp4Js.Event.EventProvider.prototype.addListener;
+Xmpp4Js.Event.EventProvider.prototype.un = Xmpp4Js.Event.EventProvider.prototype.removeListener;
\ No newline at end of file
Modified: trunk/src/main/javascript/JabberClient.js
===================================================================
--- trunk/src/main/javascript/JabberClient.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/JabberClient.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -622,7 +622,7 @@
}
}
-Ext.extend(Xmpp4Js.JabberConnection, Ext.util.Observable, Xmpp4Js.JabberConnection.prototype);
+Ext.extend(Xmpp4Js.JabberConnection, Xmpp4Js.Event.EventProvider, Xmpp4Js.JabberConnection.prototype);
/**
* @constructor
Modified: trunk/src/main/javascript/PluginManager.js
===================================================================
--- trunk/src/main/javascript/PluginManager.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/PluginManager.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -92,7 +92,7 @@
}
}
-Ext.extend( PluginManager, Ext.util.Observable, PluginManager.prototype );
+Ext.extend( PluginManager, Xmpp4Js.Event.EventProvider, PluginManager.prototype );
Modified: trunk/src/main/javascript/XmppConnection.js
===================================================================
--- trunk/src/main/javascript/XmppConnection.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/XmppConnection.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -264,5 +264,5 @@
}
}
-Ext.extend( Xmpp4Js.Connection, Ext.util.Observable, Xmpp4Js.Connection.prototype );
+Ext.extend( Xmpp4Js.Connection, Xmpp4Js.Event.EventProvider, Xmpp4Js.Connection.prototype );
Modified: trunk/src/main/javascript/chat/Chat.js
===================================================================
--- trunk/src/main/javascript/chat/Chat.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/chat/Chat.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -137,4 +137,4 @@
}
};
-Ext.extend(Xmpp4Js.Chat.Chat, Ext.util.Observable, Xmpp4Js.Chat.Chat.prototype);
+Ext.extend(Xmpp4Js.Chat.Chat, Xmpp4Js.Event.EventProvider, Xmpp4Js.Chat.Chat.prototype);
Modified: trunk/src/main/javascript/chat/ChatManager.js
===================================================================
--- trunk/src/main/javascript/chat/ChatManager.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/chat/ChatManager.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -240,4 +240,4 @@
};
-Ext.extend(Xmpp4Js.Chat.ChatManager, Ext.util.Observable, Xmpp4Js.Chat.ChatManager.prototype);
\ No newline at end of file
+Ext.extend(Xmpp4Js.Chat.ChatManager, Xmpp4Js.Event.EventProvider, Xmpp4Js.Chat.ChatManager.prototype);
\ No newline at end of file
Modified: trunk/src/main/javascript/ext/ServiceDisco.js
===================================================================
--- trunk/src/main/javascript/ext/ServiceDisco.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/ext/ServiceDisco.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -271,7 +271,7 @@
return instances[con.id];
};
-Ext.extend( ServiceDiscoManager, Ext.util.Observable, ServiceDiscoManager.prototype );
+Ext.extend( ServiceDiscoManager, Xmpp4Js.Event.EventProvider, ServiceDiscoManager.prototype );
Modified: trunk/src/main/javascript/muc/MucManager.js
===================================================================
--- trunk/src/main/javascript/muc/MucManager.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/muc/MucManager.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -73,4 +73,4 @@
}
}
-Ext.extend( Xmpp4Js.Muc.MucManager, Ext.util.Observable, Xmpp4Js.Muc.MucManager.prototype);
\ No newline at end of file
+Ext.extend( Xmpp4Js.Muc.MucManager, Xmpp4Js.Event.EventProvider, Xmpp4Js.Muc.MucManager.prototype);
\ No newline at end of file
Modified: trunk/src/main/javascript/muc/MucRoom.js
===================================================================
--- trunk/src/main/javascript/muc/MucRoom.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/muc/MucRoom.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -24,4 +24,4 @@
}
}
-Ext.extend( Xmpp4Js.Muc.MucRoom, Ext.util.Observable, Xmpp4Js.Muc.MucRoom.prototype);
\ No newline at end of file
+Ext.extend( Xmpp4Js.Muc.MucRoom, Xmpp4Js.Event.EventProvider, Xmpp4Js.Muc.MucRoom.prototype);
\ No newline at end of file
Modified: trunk/src/main/javascript/roster/PresenceManager.js
===================================================================
--- trunk/src/main/javascript/roster/PresenceManager.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/roster/PresenceManager.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -116,7 +116,7 @@
}
}
-Ext.extend(Xmpp4Js.Roster.PresenceManager, Ext.util.Observable, Xmpp4Js.Roster.PresenceManager.prototype);
+Ext.extend(Xmpp4Js.Roster.PresenceManager, Xmpp4Js.Event.EventProvider, Xmpp4Js.Roster.PresenceManager.prototype);
Modified: trunk/src/main/javascript/roster/RosterItemManager.js
===================================================================
--- trunk/src/main/javascript/roster/RosterItemManager.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/roster/RosterItemManager.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -214,4 +214,4 @@
}
}
-Ext.extend( Xmpp4Js.Roster.RosterItemManager, Ext.util.Observable, Xmpp4Js.Roster.RosterItemManager.prototype);
+Ext.extend( Xmpp4Js.Roster.RosterItemManager, Xmpp4Js.Event.EventProvider, Xmpp4Js.Roster.RosterItemManager.prototype);
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -483,4 +483,4 @@
}
}
-Ext.extend( Xmpp4Js.Transport.Base, Ext.util.Observable, Xmpp4Js.Transport.Base.prototype );
+Ext.extend( Xmpp4Js.Transport.Base, Xmpp4Js.Event.EventProvider, Xmpp4Js.Transport.Base.prototype );
Modified: trunk/src/main/javascript/workflow/Login.js
===================================================================
--- trunk/src/main/javascript/workflow/Login.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/workflow/Login.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -94,4 +94,4 @@
}
};
-Ext.extend( Xmpp4Js.Workflow.Login, Ext.util.Observable, Xmpp4Js.Workflow.Login.prototype );
\ No newline at end of file
+Ext.extend( Xmpp4Js.Workflow.Login, Xmpp4Js.Event.EventProvider, Xmpp4Js.Workflow.Login.prototype );
\ No newline at end of file
Modified: trunk/src/main/javascript/workflow/Registration.js
===================================================================
--- trunk/src/main/javascript/workflow/Registration.js 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/main/javascript/workflow/Registration.js 2008-07-07 18:34:42 UTC (rev 727)
@@ -67,4 +67,4 @@
}
};
-Ext.extend( Xmpp4Js.Workflow.Registration, Ext.util.Observable, Xmpp4Js.Workflow.Registration.prototype );
\ No newline at end of file
+Ext.extend( Xmpp4Js.Workflow.Registration, Xmpp4Js.Event.EventProvider, Xmpp4Js.Workflow.Registration.prototype );
\ No newline at end of file
Modified: trunk/src/test/javascript/DelegateManagerTest.html
===================================================================
--- trunk/src/test/javascript/DelegateManagerTest.html 2008-07-07 00:24:29 UTC (rev 726)
+++ trunk/src/test/javascript/DelegateManagerTest.html 2008-07-07 18:34:42 UTC (rev 727)
@@ -34,6 +34,24 @@
assertEquals( 1, execCount );
}
+function testAddDelegate_One_Scope() {
+
+ var expectedScope = {
+ field: "abc123"
+ }
+ var actualScope;
+
+ var method = function() {
+ actualScope = this;
+ }.bind(expectedScope);
+
+ dm.add(method);
+
+ dm.fire();
+
+ assertEquals( "Scope did not match", expectedScope, actualScope );
+}
+
function testAddDelegate_Many() {
var execCount = 0;
Added: trunk/src/test/javascript/EventProviderTest.html
===================================================================
--- trunk/src/test/javascript/EventProviderTest.html (rev 0)
+++ trunk/src/test/javascript/EventProviderTest.html 2008-07-07 18:34:42 UTC (rev 727)
@@ -0,0 +1,206 @@
+<html>
+ <head>
+ <title>JSUnit - RosterWindowTest</title>
+ <script language="javascript" src="app/jsUnitCore.js"></script>
+
+ <script type="text/javascript" src="includes.js"></script>
+ <script type="text/javascript" src="common-test-library.js"></script>
+
+
+ </head>
+ <body>
+ <script type="text/javascript">
+
+
+var DummyClass = function() {
+ this.addEvents({
+ "something" : true,
+ "somethingelse" : true
+ });
+}
+
+Ext.extend( DummyClass, Xmpp4Js.Event.EventProvider, {} );
+
+var dummy;
+
+function setUp() {
+ dummy = new DummyClass();
+}
+function tearDown() {
+ dummy = null;
+}
+
+// TODO test Xmpp4Js.Ext.PacketExtensionProvider itself.
+
+function testAddListenerSingle() {
+
+ var eventFired = false;
+
+ dummy.on("something", function() {
+ eventFired = true;
+ });
+
+ dummy.fireEvent( "something" );
+
+ assertTrue( "Event was not fired", eventFired );
+}
+
+function testAddListenerSingleArg() {
+
+ var expectedArgument = "abc123";
+ var actualArgument;
+
+ dummy.on("something", function(arg) {
+ actualArgument = arg;
+ });
+
+ dummy.fireEvent( "something", expectedArgument );
+
+ assertEquals( "Argument did not match", expectedArgument, actualArgument);
+}
+
+function testAddListenerSingleScope() {
+
+ var expectedScope = {
+ field: "abc123"
+ };
+ var actualScope;
+
+ dummy.on("something", function() {
+ actualScope = this;
+ }, expectedScope);
+
+ dummy.fireEvent( "something" );
+
+ // assertSame?
+ assertEquals( "Scope did not match", expectedScope, actualScope);
+ assertEquals( "Field on scope did not match", expectedScope.field, actualScope.field);
+}
+
+function testAddListenerMultiple() {
+
+ var somethingFired = false;
+ var somethingelseFired = false;
+
+ dummy.on({
+ "something": function() {
+ somethingFired = true;
+ },
+ "somethingelse": function() {
+ somethingelseFired = true;
+ }
+ });
+
+ dummy.fireEvent( "something" );
+ dummy.fireEvent( "somethingelse" );
+
+ assertTrue( "Event was not fired (something)", somethingFired );
+ assertTrue( "Event was not fired (somethingelse)", somethingelseFired );
+}
+
+// scope can not be passed in arguments
+function testAddListenerMultipleScopeInline() {
+
+ var expectedScope = {
+ field: "abc123"
+ };
+ var actualScope;
+
+ dummy.on({
+ scope: expectedScope,
+
+ "something": function() {
+ actualScope = this;
+ }
+ });
+
+ dummy.fireEvent( "something" );
+
+ // assertSame?
+ assertEquals( "Scope did not match", expectedScope, actualScope);
+ assertEquals( "Field on scope did not match", expectedScope.field, actualScope.field);
+}
+
+function testRemoveListenerSingle() {
+
+ var eventFired = false;
+ var somethingListener = function() {
+ eventFired = true;
+ };
+
+
+ dummy.on("something", somethingListener);
+ dummy.un("something", somethingListener);
+
+ dummy.fireEvent( "something" );
+
+ assertFalse( "Event WAS fired but should not have been", eventFired );
+
+}
+
+function testRemoveListenerMultiple() {
+
+ var somethingFired = false;
+ var somethingelseFired = false;
+
+ var somethingListner = function() {
+ somethingFired = true;
+ };
+
+ var somethingelseListener = function() {
+ somethingelseFired = true;
+ }
+
+ dummy.on({
+ "something": somethingListner,
+ "somethingelse": somethingelseListener
+ });
+
+ dummy.un({
+ "something": somethingListner,
+ "somethingelse": somethingelseListener
+ });
+
+ dummy.fireEvent( "something" );
+ dummy.fireEvent( "somethingelse" );
+
+ assertFalse( "Event WAS fired but should not have been (something)", somethingFired );
+ assertFalse( "Event WAS fired but should not have been (somethingelse)", somethingelseFired );
+}
+
+function testAddListenerSingleOptionSingle() {
+
+
+ var eventFiredCount = 0;
+
+ dummy.on("something", function() {
+ eventFiredCount++
+ }, undefined, {single:true});
+
+ dummy.fireEvent( "something" );
+ dummy.fireEvent( "something" );
+
+ assertEquals( "Event was fired more than once", 1, eventFiredCount );
+}
+
+function BROKEN_testAddListenerSingleOptionSingle_Recursion() {
+
+
+ var eventFiredCount = 0;
+
+ dummy.on("something", function() {
+ eventFiredCount++
+ dummy.fireEvent( "something" );
+ }, undefined, {single:true});
+
+ dummy.fireEvent( "something" );
+
+ assertEquals( "Event was fired more than once", 1, eventFiredCount );
+}
+
+
+ </script>
+ </body>
+</html>
+
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-07 00:24:21
|
Revision: 726
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=726&view=rev
Author: h-iverson
Date: 2008-07-06 17:24:29 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
remove the script element when it has been loaded, to avoid excess garbage building up in DOM
Modified Paths:
--------------
trunk/src/main/javascript/transport/Script.js
Modified: trunk/src/main/javascript/transport/Script.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js 2008-07-06 05:35:56 UTC (rev 725)
+++ trunk/src/main/javascript/transport/Script.js 2008-07-07 00:24:29 UTC (rev 726)
@@ -82,8 +82,20 @@
scriptElem.setAttribute( "type", "text/javascript" );
scriptElem.setAttribute( "src", requestUrl );
scriptElem.setAttribute( "id", "xmpp4js"+"."+this.sid+"."+packetNode.getAttribute("rid") );
-
+ // remove the script element when it's been loaded.
+ if(scriptElem.addEventListener) {
+ scriptElem.addEventListener("load", function() {
+ document.body.removeChild( scriptElem );
+ }, false );
+ } else {
+ scriptElem.onreadystatechange = function() {
+ if(scriptElem.readyState == 4 || scriptElem.readyState == "loaded") {
+ document.body.removeChild( scriptElem );
+ }
+ }
+ }
+
document.body.appendChild( scriptElem );
},
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-06 05:35:47
|
Revision: 725
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=725&view=rev
Author: h-iverson
Date: 2008-07-05 22:35:56 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
added security exception adder
Modified Paths:
--------------
xmpp4js-launcher/src/main/webapp/simpleclient.html
Modified: xmpp4js-launcher/src/main/webapp/simpleclient.html
===================================================================
--- xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-05 21:39:49 UTC (rev 724)
+++ xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-06 05:35:56 UTC (rev 725)
@@ -32,6 +32,13 @@
<dt></dt>
<dd><button type="submit">Login</button></dd>
+
+
+ <dt>Security Exception</dt>
+ <dd>
+ <button onclick="document.location.href=this.form.endpoint.value">Can't Connect? Add Exception</button><br/>
+ <small>Add the exception when prompted, and come back to this page</small>
+ </dd>
</dl>
</form>
</div>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-05 21:39:41
|
Revision: 724
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=724&view=rev
Author: h-iverson
Date: 2008-07-05 14:39:49 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
added transport selector
Modified Paths:
--------------
xmpp4js-launcher/src/main/webapp/simpleclient.html
Modified: xmpp4js-launcher/src/main/webapp/simpleclient.html
===================================================================
--- xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-05 21:31:15 UTC (rev 723)
+++ xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-05 21:39:49 UTC (rev 724)
@@ -21,6 +21,15 @@
<dt>Password</dt>
<dd><input type="password" name="password"/></dd>
+ <dt>Transport</dt>
+ <dd><select name="transport" onchange="this.form.endpoint.value = (this.value == 'script' ? 'https://bosh.soashable.com:7443/http-bind/' : '/http-bind/');">
+ <option value="script" onclick="">Script (X-Domain)</option>
+ <option value="bosh">BOSH (Local Servlet)</option>
+ </select></dd>
+
+ <dt>Transport Endpoint</dt>
+ <dd><input type="text" name="endpoint" value="https://bosh.soashable.com:7443/http-bind/"/></dd>
+
<dt></dt>
<dd><button type="submit">Login</button></dd>
</dl>
@@ -70,12 +79,13 @@
* Connect and set handler that will attempt login
*/
login: function(form) {
+
+ // store this for onConnectForLogin
+ this.loginForm = form;
+
// set up the connection
this.init();
- // store this for onConnectForLogin
- this.loginForm = form;
-
// set a listener to call onConnectForLogin once when connected
this.con.on("connect", this.onConnectForLogin, this, {single: true} );
@@ -130,11 +140,17 @@
init: function() {
var stanzaProvider = new Xmpp4Js.Packet.StanzaProvider();
stanzaProvider.registerDefaultProviders();
+
+ var transportClasses = {bosh: Xmpp4Js.Transport.BOSH, script: Xmpp4Js.Transport.Script};
+
+ var endpoint = this.loginForm.endpoint.value;
this.con = new Xmpp4Js.Connection({
transport: {
- clazz: Xmpp4Js.Transport.Script,
- endpoint: "https://bosh.soashable.com:7443/http-bind/" // where your BOSH server is running.
+ useKeys: true,
+
+ clazz: transportClasses[ this.loginForm.transport.value ],
+ endpoint: endpoint // where your BOSH server is running.
// NOTE: same origin policy means you need some sort of proxt, or a servlet.
},
stanzaProvider: stanzaProvider,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-05 21:31:07
|
Revision: 723
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=723&view=rev
Author: h-iverson
Date: 2008-07-05 14:31:15 -0700 (Sat, 05 Jul 2008)
Log Message:
-----------
made script transport raise error events, and added useKeys option for security
Modified Paths:
--------------
trunk/src/main/javascript/transport/Base.js
trunk/src/main/javascript/transport/Script.js
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-05 05:56:32 UTC (rev 722)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-05 21:31:15 UTC (rev 723)
@@ -118,7 +118,7 @@
* The keysequence object
* @private
*/
- this.keySeq = null;
+ this.keySeq = config.useKeys ? new KeySequence(25): null;
/**
* The max number of requests that can be open at once, sent by the server
@@ -133,6 +133,12 @@
*/
this.hold = null;
+ /**
+ *
+ * @private
+ */
+ this.polling = 5;
+
/**
* The number of open XHR requests. Used for polling.
* @private
@@ -223,7 +229,7 @@
packetNode.setAttribute( "xmlns:xmpp", "urn:xmpp:xbosh");
packetNode.setAttribute( "xmpp:version", "1.0" );
-
+
this.on("recv", this.onBeginSessionResponse, this, {single:true});
this.write( packetNode );
@@ -254,6 +260,10 @@
// FIXME ideally xhr's timeout should be updated
this.wait = packetNode.getAttribute("wait").toString();
}
+
+ if( packetNode.hasAttribute("polling") ) {
+ this.polling = packetNode.getAttribute("polling").toString();
+ }
this.startup();
@@ -360,6 +370,14 @@
* @private
*/
sendPoll: function() {
+ // if we're trying to poll too frequently
+ /*var now = new Date().getTime();
+ if( this.lastPoll != undefined && this.polling != 0 && (now - this.lastPoll < (this.polling * 1000)) ) {
+ return;
+ }
+ this.lastPoll = now;
+ */
+
if( this.openRequestCount == 0 && this.queue.length == 0 ) {
var packetNode = this.createPacketNode();
this.write( packetNode );
Modified: trunk/src/main/javascript/transport/Script.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js 2008-07-05 05:56:32 UTC (rev 722)
+++ trunk/src/main/javascript/transport/Script.js 2008-07-05 21:31:15 UTC (rev 723)
@@ -45,6 +45,12 @@
var superConfig = config;
+ // TODO handle multiple connections...
+ window._BOSH_ = function(xml) {
+ this.onWriteResponse(xml);
+ }.bind(this);
+
+
Xmpp4Js.Transport.Script.superclass.constructor.call( this, config );
}
@@ -77,11 +83,7 @@
scriptElem.setAttribute( "src", requestUrl );
scriptElem.setAttribute( "id", "xmpp4js"+"."+this.sid+"."+packetNode.getAttribute("rid") );
- // TODO handle multiple connections...
- window._BOSH_ = function(xml) {
- this.onWriteResponse(xml);
- }.bind(this);
-
+
document.body.appendChild( scriptElem );
},
@@ -97,7 +99,40 @@
// TODO character replacement (18.3)?
var packetNode = new DOMImplementation().loadXML( xml ).documentElement;
- this.fireEvent( "recv", packetNode );
+
+ if(packetNode.getAttribute("type").toString() == "terminal") {
+ this.shutdown();
+
+ var condition = null;
+ if( packetNode != null ) {
+ condition = packetNode.getAttribute( "condition" ).toString();
+ } else if( !response.status ) {
+ condition = "undefined-condition";
+ } else if( response.status != 200 ){
+ condition = "status."+response.status;
+ } else {
+ condition = "undefined-condition";
+ }
+
+ var title = Xmpp4Js.PacketFilter.TerminalErrorPacketFilter.conditions[ condition ].title;
+ var message = Xmpp4Js.PacketFilter.TerminalErrorPacketFilter.conditions[ condition ].message;
+
+ this.fireEvent( "termerror", title, message, packetNode );
+ } else if( packetNode.getAttribute("type").toString() == "error" ) {
+ // 17.3 Recoverable Binding Conditions
+
+ // TODO this should attempt to resend all packets back
+ // to the one that created the error. This could be
+ // implemented by putting each sent packet into a queue
+ // and removing it upon a successful response.
+ //
+ // Ideally this error event would not even be visible beyond
+ // the the BOSH transport.
+
+ this.fireEvent( "error", packetNode );
+ } else {
+ this.fireEvent( "recv", packetNode );
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-05 05:56:24
|
Revision: 722
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=722&view=rev
Author: h-iverson
Date: 2008-07-04 22:56:32 -0700 (Fri, 04 Jul 2008)
Log Message:
-----------
use script syntax
Modified Paths:
--------------
xmpp4js-launcher/src/main/webapp/simpleclient.html
Modified: xmpp4js-launcher/src/main/webapp/simpleclient.html
===================================================================
--- xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-05 05:51:13 UTC (rev 721)
+++ xmpp4js-launcher/src/main/webapp/simpleclient.html 2008-07-05 05:56:32 UTC (rev 722)
@@ -133,8 +133,8 @@
this.con = new Xmpp4Js.Connection({
transport: {
- clazz: Xmpp4Js.Transport.BOSH,
- endpoint: "/http-bind/" // where your BOSH server is running.
+ clazz: Xmpp4Js.Transport.Script,
+ endpoint: "https://bosh.soashable.com:7443/http-bind/" // where your BOSH server is running.
// NOTE: same origin policy means you need some sort of proxt, or a servlet.
},
stanzaProvider: stanzaProvider,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <h-i...@us...> - 2008-07-05 05:51:07
|
Revision: 721
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=721&view=rev
Author: h-iverson
Date: 2008-07-04 22:51:13 -0700 (Fri, 04 Jul 2008)
Log Message:
-----------
script syntax is now working
Modified Paths:
--------------
trunk/src/main/javascript/transport/Script.js
Modified: trunk/src/main/javascript/transport/Script.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js 2008-07-05 05:06:47 UTC (rev 720)
+++ trunk/src/main/javascript/transport/Script.js 2008-07-05 05:51:13 UTC (rev 721)
@@ -65,15 +65,21 @@
this.prepareWrite( packetNode );
+ var xml = packetNode.toString();
+
// TODO check for max length constraints in browsers
- var requestUrl = this.endpoint+"?body="+xml;
+ // HACK substr(5) takes out body=; there should be a method to
+ // only encode the right-hand side of the params.
+ var requestUrl = this.endpoint+"?"+Ext.urlEncode({body: xml}).substr(5);
+
var scriptElem = document.createElement( "script" );
scriptElem.setAttribute( "type", "text/javascript" );
scriptElem.setAttribute( "src", requestUrl );
+ scriptElem.setAttribute( "id", "xmpp4js"+"."+this.sid+"."+packetNode.getAttribute("rid") );
// TODO handle multiple connections...
window._BOSH_ = function(xml) {
- this.handleResponse();
+ this.onWriteResponse(xml);
}.bind(this);
document.body.appendChild( scriptElem );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <h-i...@us...> - 2008-07-05 05:06:02
|
Revision: 719
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=719&view=rev
Author: h-iverson
Date: 2008-07-04 22:05:59 -0700 (Fri, 04 Jul 2008)
Log Message:
-----------
put open requests into base
Modified Paths:
--------------
trunk/src/main/javascript/transport/BOSH.js
trunk/src/main/javascript/transport/Base.js
trunk/src/main/javascript/transport/Script.js.js
Modified: trunk/src/main/javascript/transport/BOSH.js
===================================================================
--- trunk/src/main/javascript/transport/BOSH.js 2008-07-05 04:52:49 UTC (rev 718)
+++ trunk/src/main/javascript/transport/BOSH.js 2008-07-05 05:05:59 UTC (rev 719)
@@ -48,12 +48,6 @@
*/
this.xhr = this.createXhr();
- /**
- * The number of open XHR requests. Used for polling.
- * @private
- */
- this.openRequestCount = 0;
-
var superConfig = config;
Xmpp4Js.Transport.BOSH.superclass.constructor.call( this, superConfig );
Modified: trunk/src/main/javascript/transport/Base.js
===================================================================
--- trunk/src/main/javascript/transport/Base.js 2008-07-05 04:52:49 UTC (rev 718)
+++ trunk/src/main/javascript/transport/Base.js 2008-07-05 05:05:59 UTC (rev 719)
@@ -133,6 +133,12 @@
*/
this.hold = null;
+ /**
+ * The number of open XHR requests. Used for polling.
+ * @private
+ */
+ this.openRequestCount = 0;
+
var superConfig = config;
Modified: trunk/src/main/javascript/transport/Script.js.js
===================================================================
--- trunk/src/main/javascript/transport/Script.js.js 2008-07-05 04:52:49 UTC (rev 718)
+++ trunk/src/main/javascript/transport/Script.js.js 2008-07-05 05:05:59 UTC (rev 719)
@@ -36,6 +36,15 @@
* 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 );
}
@@ -57,7 +66,7 @@
this.prepareWrite( packetNode );
// TODO check for max length constraints in browsers
- var requestUrl = "http://"+this.server+":"+this.port+"/"+this.endpoint+"?body="+xml;
+ var requestUrl = this.endpoint+"?body="+xml;
var scriptElem = document.createElement( "script" );
scriptElem.setAttribute( "type", "text/javascript" );
scriptElem.setAttribute( "src", requestUrl );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|