[76] | 1 | /*! |
---|
| 2 | * Ext JS Library 3.4.0 |
---|
| 3 | * Copyright(c) 2006-2011 Sencha Inc. |
---|
| 4 | * licensing@sencha.com |
---|
| 5 | * http://www.sencha.com/license |
---|
| 6 | */ |
---|
| 7 | /** |
---|
| 8 | * @class Ext.direct.Provider |
---|
| 9 | * @extends Ext.util.Observable |
---|
| 10 | * <p>Ext.direct.Provider is an abstract class meant to be extended.</p> |
---|
| 11 | * |
---|
| 12 | * <p>For example ExtJs implements the following subclasses:</p> |
---|
| 13 | * <pre><code> |
---|
| 14 | Provider |
---|
| 15 | | |
---|
| 16 | +---{@link Ext.direct.JsonProvider JsonProvider} |
---|
| 17 | | |
---|
| 18 | +---{@link Ext.direct.PollingProvider PollingProvider} |
---|
| 19 | | |
---|
| 20 | +---{@link Ext.direct.RemotingProvider RemotingProvider} |
---|
| 21 | * </code></pre> |
---|
| 22 | * @abstract |
---|
| 23 | */ |
---|
| 24 | Ext.direct.Provider = Ext.extend(Ext.util.Observable, { |
---|
| 25 | /** |
---|
| 26 | * @cfg {String} id |
---|
| 27 | * The unique id of the provider (defaults to an {@link Ext#id auto-assigned id}). |
---|
| 28 | * You should assign an id if you need to be able to access the provider later and you do |
---|
| 29 | * not have an object reference available, for example: |
---|
| 30 | * <pre><code> |
---|
| 31 | Ext.Direct.addProvider( |
---|
| 32 | { |
---|
| 33 | type: 'polling', |
---|
| 34 | url: 'php/poll.php', |
---|
| 35 | id: 'poll-provider' |
---|
| 36 | } |
---|
| 37 | ); |
---|
| 38 | |
---|
| 39 | var p = {@link Ext.Direct Ext.Direct}.{@link Ext.Direct#getProvider getProvider}('poll-provider'); |
---|
| 40 | p.disconnect(); |
---|
| 41 | * </code></pre> |
---|
| 42 | */ |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * @cfg {Number} priority |
---|
| 46 | * Priority of the request. Lower is higher priority, <tt>0</tt> means "duplex" (always on). |
---|
| 47 | * All Providers default to <tt>1</tt> except for PollingProvider which defaults to <tt>3</tt>. |
---|
| 48 | */ |
---|
| 49 | priority: 1, |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * @cfg {String} type |
---|
| 53 | * <b>Required</b>, <tt>undefined</tt> by default. The <tt>type</tt> of provider specified |
---|
| 54 | * to {@link Ext.Direct Ext.Direct}.{@link Ext.Direct#addProvider addProvider} to create a |
---|
| 55 | * new Provider. Acceptable values by default are:<div class="mdetail-params"><ul> |
---|
| 56 | * <li><b><tt>polling</tt></b> : {@link Ext.direct.PollingProvider PollingProvider}</li> |
---|
| 57 | * <li><b><tt>remoting</tt></b> : {@link Ext.direct.RemotingProvider RemotingProvider}</li> |
---|
| 58 | * </ul></div> |
---|
| 59 | */ |
---|
| 60 | |
---|
| 61 | // private |
---|
| 62 | constructor : function(config){ |
---|
| 63 | Ext.apply(this, config); |
---|
| 64 | this.addEvents( |
---|
| 65 | /** |
---|
| 66 | * @event connect |
---|
| 67 | * Fires when the Provider connects to the server-side |
---|
| 68 | * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}. |
---|
| 69 | */ |
---|
| 70 | 'connect', |
---|
| 71 | /** |
---|
| 72 | * @event disconnect |
---|
| 73 | * Fires when the Provider disconnects from the server-side |
---|
| 74 | * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}. |
---|
| 75 | */ |
---|
| 76 | 'disconnect', |
---|
| 77 | /** |
---|
| 78 | * @event data |
---|
| 79 | * Fires when the Provider receives data from the server-side |
---|
| 80 | * @param {Ext.direct.Provider} provider The {@link Ext.direct.Provider Provider}. |
---|
| 81 | * @param {event} e The {@link Ext.Direct#eventTypes Ext.Direct.Event type} that occurred. |
---|
| 82 | */ |
---|
| 83 | 'data', |
---|
| 84 | /** |
---|
| 85 | * @event exception |
---|
| 86 | * Fires when the Provider receives an exception from the server-side |
---|
| 87 | */ |
---|
| 88 | 'exception' |
---|
| 89 | ); |
---|
| 90 | Ext.direct.Provider.superclass.constructor.call(this, config); |
---|
| 91 | }, |
---|
| 92 | |
---|
| 93 | /** |
---|
| 94 | * Returns whether or not the server-side is currently connected. |
---|
| 95 | * Abstract method for subclasses to implement. |
---|
| 96 | */ |
---|
| 97 | isConnected: function(){ |
---|
| 98 | return false; |
---|
| 99 | }, |
---|
| 100 | |
---|
| 101 | /** |
---|
| 102 | * Abstract methods for subclasses to implement. |
---|
| 103 | */ |
---|
| 104 | connect: Ext.emptyFn, |
---|
| 105 | |
---|
| 106 | /** |
---|
| 107 | * Abstract methods for subclasses to implement. |
---|
| 108 | */ |
---|
| 109 | disconnect: Ext.emptyFn |
---|
| 110 | }); |
---|