-<html>\r
-<head>\r
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> \r
- <title>The source code</title>\r
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body onload="prettyPrint();">\r
- <pre class="prettyprint lang-js"><div id="cls-Ext.direct.PollingProvider"></div>/**\r
- * @class Ext.direct.PollingProvider\r
- * @extends Ext.direct.JsonProvider\r
- *\r
- * <p>Provides for repetitive polling of the server at distinct {@link #interval intervals}.\r
- * The initial request for data originates from the client, and then is responded to by the\r
- * server.</p>\r
- * \r
- * <p>All configurations for the PollingProvider should be generated by the server-side\r
- * API portion of the Ext.Direct stack.</p>\r
- *\r
- * <p>An instance of PollingProvider may be created directly via the new keyword or by simply\r
- * specifying <tt>type = 'polling'</tt>. For example:</p>\r
- * <pre><code>\r
-var pollA = new Ext.direct.PollingProvider({\r
- type:'polling',\r
- url: 'php/pollA.php',\r
-});\r
-Ext.Direct.addProvider(pollA);\r
-pollA.disconnect();\r
-\r
-Ext.Direct.addProvider(\r
- {\r
- type:'polling',\r
- url: 'php/pollB.php',\r
- id: 'pollB-provider'\r
- }\r
-);\r
-var pollB = Ext.Direct.getProvider('pollB-provider');\r
- * </code></pre>\r
- */\r
-Ext.direct.PollingProvider = Ext.extend(Ext.direct.JsonProvider, {\r
- <div id="cfg-Ext.direct.PollingProvider-priority"></div>/**\r
- * @cfg {Number} priority\r
- * Priority of the request (defaults to <tt>3</tt>). See {@link Ext.direct.Provider#priority}.\r
- */\r
- // override default priority\r
- priority: 3,\r
- \r
- <div id="cfg-Ext.direct.PollingProvider-interval"></div>/**\r
- * @cfg {Number} interval\r
- * How often to poll the server-side in milliseconds (defaults to <tt>3000</tt> - every\r
- * 3 seconds).\r
- */\r
- interval: 3000,\r
-\r
- <div id="cfg-Ext.direct.PollingProvider-baseParams"></div>/**\r
- * @cfg {Object} baseParams An object containing properties which are to be sent as parameters\r
- * on every polling request\r
- */\r
- \r
- <div id="cfg-Ext.direct.PollingProvider-url"></div>/**\r
- * @cfg {String/Function} url\r
- * The url which the PollingProvider should contact with each request. This can also be\r
- * an imported Ext.Direct method which will accept the baseParams as its only argument.\r
- */\r
-\r
- // private\r
- constructor : function(config){\r
- Ext.direct.PollingProvider.superclass.constructor.call(this, config);\r
- this.addEvents(\r
- <div id="event-Ext.direct.PollingProvider-beforepoll"></div>/**\r
- * @event beforepoll\r
- * Fired immediately before a poll takes place, an event handler can return false\r
- * in order to cancel the poll.\r
- * @param {Ext.direct.PollingProvider}\r
- */\r
- 'beforepoll', \r
- <div id="event-Ext.direct.PollingProvider-poll"></div>/**\r
- * @event poll\r
- * This event has not yet been implemented.\r
- * @param {Ext.direct.PollingProvider}\r
- */\r
- 'poll'\r
- );\r
- },\r
-\r
- // inherited\r
- isConnected: function(){\r
- return !!this.pollTask;\r
- },\r
-\r
- <div id="method-Ext.direct.PollingProvider-connect"></div>/**\r
- * Connect to the server-side and begin the polling process. To handle each\r
- * response subscribe to the data event.\r
- */\r
- connect: function(){\r
- if(this.url && !this.pollTask){\r
- this.pollTask = Ext.TaskMgr.start({\r
- run: function(){\r
- if(this.fireEvent('beforepoll', this) !== false){\r
- if(typeof this.url == 'function'){\r
- this.url(this.baseParams);\r
- }else{\r
- Ext.Ajax.request({\r
- url: this.url,\r
- callback: this.onData,\r
- scope: this,\r
- params: this.baseParams\r
- });\r
- }\r
- }\r
- },\r
- interval: this.interval,\r
- scope: this\r
- });\r
- this.fireEvent('connect', this);\r
- }else if(!this.url){\r
- throw 'Error initializing PollingProvider, no url configured.';\r
- }\r
- },\r
-\r
- <div id="method-Ext.direct.PollingProvider-disconnect"></div>/**\r
- * Disconnect from the server-side and stop the polling process. The disconnect\r
- * event will be fired on a successful disconnect.\r
- */\r
- disconnect: function(){\r
- if(this.pollTask){\r
- Ext.TaskMgr.stop(this.pollTask);\r
- delete this.pollTask;\r
- this.fireEvent('disconnect', this);\r
- }\r
- },\r
-\r
- // private\r
- onData: function(opt, success, xhr){\r
- if(success){\r
- var events = this.getEvents(xhr);\r
- for(var i = 0, len = events.length; i < len; i++){\r
- var e = events[i];\r
- this.fireEvent('data', this, e);\r
- }\r
- }else{\r
- var e = new Ext.Direct.ExceptionEvent({\r
- data: e,\r
- code: Ext.Direct.exceptions.TRANSPORT,\r
- message: 'Unable to connect to the server.',\r
- xhr: xhr\r
- });\r
- this.fireEvent('data', this, e);\r
- }\r
- }\r
-});\r
-\r
-Ext.Direct.PROVIDERS['polling'] = Ext.direct.PollingProvider;</pre> \r
-</body>\r
-</html>
\ No newline at end of file
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <title>The source code</title>
+ <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+ <style type="text/css">
+ .highlight { display: block; background-color: #ddd; }
+ </style>
+ <script type="text/javascript">
+ function highlight() {
+ document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
+ }
+ </script>
+</head>
+<body onload="prettyPrint(); highlight();">
+ <pre class="prettyprint lang-js"><span id='Ext-direct-PollingProvider'>/**
+</span> * @class Ext.direct.PollingProvider
+ * @extends Ext.direct.JsonProvider
+ *
+ * <p>Provides for repetitive polling of the server at distinct {@link #interval intervals}.
+ * The initial request for data originates from the client, and then is responded to by the
+ * server.</p>
+ *
+ * <p>All configurations for the PollingProvider should be generated by the server-side
+ * API portion of the Ext.Direct stack.</p>
+ *
+ * <p>An instance of PollingProvider may be created directly via the new keyword or by simply
+ * specifying <tt>type = 'polling'</tt>. For example:</p>
+ * <pre><code>
+var pollA = new Ext.direct.PollingProvider({
+ type:'polling',
+ url: 'php/pollA.php',
+});
+Ext.direct.Manager.addProvider(pollA);
+pollA.disconnect();
+
+Ext.direct.Manager.addProvider(
+ {
+ type:'polling',
+ url: 'php/pollB.php',
+ id: 'pollB-provider'
+ }
+);
+var pollB = Ext.direct.Manager.getProvider('pollB-provider');
+ * </code></pre>
+ */
+Ext.define('Ext.direct.PollingProvider', {
+
+ /* Begin Definitions */
+
+ extend: 'Ext.direct.JsonProvider',
+
+ alias: 'direct.pollingprovider',
+
+ uses: ['Ext.direct.ExceptionEvent'],
+
+ requires: ['Ext.Ajax', 'Ext.util.DelayedTask'],
+
+ /* End Definitions */
+
+<span id='Ext-direct-PollingProvider-cfg-interval'> /**
+</span> * @cfg {Number} interval
+ * How often to poll the server-side in milliseconds. Defaults to every 3 seconds.
+ */
+ interval: 3000,
+
+<span id='Ext-direct-PollingProvider-cfg-baseParams'> /**
+</span> * @cfg {Object} baseParams
+ * An object containing properties which are to be sent as parameters on every polling request
+ */
+
+<span id='Ext-direct-PollingProvider-cfg-url'> /**
+</span> * @cfg {String/Function} url
+ * The url which the PollingProvider should contact with each request. This can also be
+ * an imported Ext.Direct method which will accept the baseParams as its only argument.
+ */
+
+ // private
+ constructor : function(config){
+ this.callParent(arguments);
+ this.addEvents(
+<span id='Ext-direct-PollingProvider-event-beforepoll'> /**
+</span> * @event beforepoll
+ * Fired immediately before a poll takes place, an event handler can return false
+ * in order to cancel the poll.
+ * @param {Ext.direct.PollingProvider} this
+ */
+ 'beforepoll',
+<span id='Ext-direct-PollingProvider-event-poll'> /**
+</span> * @event poll
+ * This event has not yet been implemented.
+ * @param {Ext.direct.PollingProvider} this
+ */
+ 'poll'
+ );
+ },
+
+ // inherited
+ isConnected: function(){
+ return !!this.pollTask;
+ },
+
+<span id='Ext-direct-PollingProvider-method-connect'> /**
+</span> * Connect to the server-side and begin the polling process. To handle each
+ * response subscribe to the data event.
+ */
+ connect: function(){
+ var me = this, url = me.url;
+
+ if (url && !me.pollTask) {
+ me.pollTask = Ext.TaskManager.start({
+ run: function(){
+ if (me.fireEvent('beforepoll', me) !== false) {
+ if (Ext.isFunction(url)) {
+ url(me.baseParams);
+ } else {
+ Ext.Ajax.request({
+ url: url,
+ callback: me.onData,
+ scope: me,
+ params: me.baseParams
+ });
+ }
+ }
+ },
+ interval: me.interval,
+ scope: me
+ });
+ me.fireEvent('connect', me);
+ } else if (!url) {
+ //<debug>
+ Ext.Error.raise('Error initializing PollingProvider, no url configured.');
+ //</debug>
+ }
+ },
+
+<span id='Ext-direct-PollingProvider-method-disconnect'> /**
+</span> * Disconnect from the server-side and stop the polling process. The disconnect
+ * event will be fired on a successful disconnect.
+ */
+ disconnect: function(){
+ var me = this;
+
+ if (me.pollTask) {
+ Ext.TaskManager.stop(me.pollTask);
+ delete me.pollTask;
+ me.fireEvent('disconnect', me);
+ }
+ },
+
+ // private
+ onData: function(opt, success, response){
+ var me = this,
+ i = 0,
+ len,
+ events;
+
+ if (success) {
+ events = me.createEvents(response);
+ for (len = events.length; i < len; ++i) {
+ me.fireEvent('data', me, events[i]);
+ }
+ } else {
+ me.fireEvent('data', me, Ext.create('Ext.direct.ExceptionEvent', {
+ data: null,
+ code: Ext.direct.Manager.self.exceptions.TRANSPORT,
+ message: 'Unable to connect to the server.',
+ xhr: response
+ }));
+ }
+ }
+});</pre>
+</body>
+</html>