[Xmpp4js-commit] SF.net SVN: xmpp4js:[754] trunk/src/main/javascript/XmppConnection.js
Status: Beta
Brought to you by:
h-iverson
|
From: <h-i...@us...> - 2008-07-27 20:36:37
|
Revision: 754
http://xmpp4js.svn.sourceforge.net/xmpp4js/?rev=754&view=rev
Author: h-iverson
Date: 2008-07-27 20:36:44 +0000 (Sun, 27 Jul 2008)
Log Message:
-----------
- moved pause / resume event listeners to their own onPause and onResume
- made shutdown / startup functions not call connect/close events. instead begin and end sessions do. this changes events a little bit, in that close is no longer called after errors
Modified Paths:
--------------
trunk/src/main/javascript/XmppConnection.js
Modified: trunk/src/main/javascript/XmppConnection.js
===================================================================
--- trunk/src/main/javascript/XmppConnection.js 2008-07-27 20:22:38 UTC (rev 753)
+++ trunk/src/main/javascript/XmppConnection.js 2008-07-27 20:36:44 UTC (rev 754)
@@ -115,31 +115,8 @@
streamerror: this.onStreamError,
beginsession: this.onBeginSession,
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 );
- }
+ pause: this.onPause,
+ resume: this.onResume
// recv will be added in beginSession.
}
});
@@ -276,6 +253,7 @@
*/
onBeginSession: function() {
this.startup();
+ this.fireEvent( "connect" );
},
/**
@@ -284,9 +262,40 @@
*/
onEndSession: function() {
this.shutdown();
+ this.fireEvent( "close" );
},
/**
+ * Event handler for when the transport session is paused. Bubbles the event
+ * through to listeners on this connection.
+ *
+ * @param {Object} pauseStruct the r/w object containing info about the pause.
+ * @private
+ */
+ onPause: function(pauseStruct) {
+ // serialize our junk (domain is covered by transport)
+ pauseStruct.jid = this.jid;
+ this.fireEvent( "pause", pauseStruct );
+ this.shutdown();
+ },
+
+ /**
+ * Event handler for when the transport session is resumed. Bubbles the event
+ * through to listeners on this connection.
+ *
+ * @param {Object} pauseStruct the r/w object containing info about the pause.
+ * @private
+ */
+ onResume: function() {
+ // deserialize our junk
+ this.domain = pauseStruct.domain;
+ this.jid = pauseStruct.jid;
+
+ this.startup();
+ this.fireEvent( "resume", pauseStruct );
+ },
+
+ /**
* Set connected to false, fire the close event, and remove the recv listener.
* @private
*/
@@ -294,7 +303,6 @@
this.transport.un("recv", this.onRecv, this );
this.connected = false;
- this.fireEvent( "close" );
},
/**
@@ -308,8 +316,6 @@
scope: this,
recv: this.onRecv
});
-
- this.fireEvent( "connect" );
},
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|