[Xmpp4js-commit] SF.net SVN: xmpp4js:[744] trunk/src/site/xdoc/code-samples.xml
Status: Beta
Brought to you by:
h-iverson
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. |