goog.labs.net.webChannel.WebChannelBase
Provided By | |
---|---|
All Implemented Interfaces |
This WebChannel implementation is branched off goog.net.BrowserChannel for now. Ongoing changes to goog.net.BrowserChannel will be back ported to this implementation as needed.
new WebChannelBase( opt_options, opt_clientVersion, opt_conn )
Parameters |
|
---|
Instance Methods
this.connect( channelPath, opt_extraParams, opt_oldSessionId, opt_oldArrayId ) → void
void
Starts the channel. This initiates connections to the server.
Parameters |
|
---|
this.correctHostPrefix( serverHostPrefix ) → (string|null)
(string|null)
Decides which host prefix should be used, if any. If there is a handler, allows the handler to validate a host prefix provided by the server, and optionally override it.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
| ||||
Returns |
|
this.createDataUri( hostPrefix, path, opt_overridePort ) → (goog.Uri|null)
(goog.Uri|null)
Not needed for testchannel.
Creates a data Uri applying logic for secondary hostprefix, port overrides, and versioning.
Specified by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||||||
Returns |
|
this.createXhrIo( hostPrefix, isStreaming ) → goog.net.XhrIo
goog.net.XhrIo
Called when creating an XhrIo object. Override in a subclass if you need to customize the behavior, for example to enable the creation of XHR's capable of calling a secondary domain. Will also allow calling a secondary domain if withCredentials (CORS) is enabled.
Specified by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.disconnect() → void
void
Disconnects and closes the channel.
this.getAllowHostPrefix() → boolean
boolean
Returns whether the channel allows the use of a subdomain. There may be cases where this isn't allowed.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getAllowStreamingMode() → boolean
boolean
Returns whether streaming mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable streaming mode for a user.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBackChannelMaxRetries() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getBackChannelUri( hostPrefix, path ) → (goog.Uri|null)
(goog.Uri|null)
this.getChannelDebug() → goog.labs.net.webChannel.WebChannelDebug
goog.labs.net.webChannel.WebChannelDebug
Returns the logger.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getConnectionState() → goog.labs.net.webChannel.ConnectionState
goog.labs.net.webChannel.ConnectionState
Not needed for testchannel. Gets the result of previous connectivity tests.
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getExtraHeaders() → (Object|null)
(Object|null)
Returns the extra HTTP headers to add to all the requests sent to the server.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getForwardChannelMaxRetries() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getForwardChannelRequestPool() → goog.labs.net.webChannel.ForwardChannelRequestPool
goog.labs.net.webChannel.ForwardChannelRequestPool
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getForwardChannelUri( path ) → (goog.Uri|null)
(goog.Uri|null)
this.getHandler() → (goog.labs.net.webChannel.WebChannelBase.Handler|null)
(goog.labs.net.webChannel.WebChannelBase.Handler|null)
Returns the handler used for channel callback events.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getHttpSessionId() → (string|null)
(string|null)
Gets the http session id.
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getHttpSessionIdParam() → (string|null)
(string|null)
Gets the parameter name for the http session id.
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getInitHeaders() → (Object|null)
(Object|null)
Returns the extra HTTP headers to add to the init requests sent to the server.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastArrayId() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastStatusCode() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getNonAckedMaps() → Array<goog.labs.net.webChannel.Wire.QueuedMap>
Array<goog.labs.net.webChannel.Wire.QueuedMap>
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getServerVersion() → number
number
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getSessionId() → string
string
Returns the session id of the channel. Only available after the channel has been opened.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getState() → goog.labs.net.webChannel.WebChannelBase.State
goog.labs.net.webChannel.WebChannelBase.State
Returns the channel state.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getWireCodec() → Object
Object
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.hasOutstandingRequests() → boolean
boolean
Returns whether there are outstanding requests servicing the channel.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isActive() → boolean
boolean
Gets whether this channel is currently active. This is used to determine the length of time to wait before retrying. This call delegates to the handler.
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.isBuffered() → boolean
boolean
Returns whether the channel is buffered or not. This may be queried in the WebChannelBase.okToMakeRequest() callback.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isClosed() → boolean
boolean
Returns whether the channel is closed
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.onFirstByteReceived( request, responseText ) → void
void
Callback from ChannelRequest for when the first byte of response body has been received. This is needed for detecting buffering proxies.
Specified by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.onRequestComplete( request ) → void
void
Callback from ChannelRequest that indicates a request has completed.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
|
this.onRequestData( request, responseText ) → void
void
Callback from ChannelRequest for when new data is received
Specified by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.sendMap( map, opt_context ) → void
void
Sends a request to the server. The format of the request is a Map data structure of key/value pairs. These maps are then encoded in a format suitable for the wire and then reconstituted as a Map data structure that the server can process.
Parameters |
|
---|
this.setAllowHostPrefix( allowHostPrefix ) → void
void
Sets whether the channel allows the use of a subdomain. There may be cases where this isn't allowed, for example, logging in with troutboard where using a subdomain causes Apache to force the user to authenticate twice.
Parameters |
|
---|
this.setAllowStreamingMode( allowStreamingMode ) → void
void
Sets whether streaming mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable streaming mode for a user.
Parameters |
|
---|
this.setChannelDebug( channelDebug ) → void
void
Sets the logger.
Parameters |
|
---|
this.setExtraHeaders( extraHeaders ) → void
void
Sets extra HTTP headers to add to all the requests sent to the server.
Parameters |
|
---|
this.setFailFast( failFast ) → void
void
When set to true, this changes the behavior of the forward channel so it will not retry requests; it will fail after one network failure, and if there was already one network failure, the request will fail immediately.
Parameters |
|
---|
this.setForwardChannelFlushCallback( callback ) → void
void
Sets (overwrites) the forward channel flush callback.
Parameters |
|
---|
this.setForwardChannelMaxRetries( retries ) → void
void
Sets the maximum number of attempts to connect to the server for forward channel requests.
Parameters |
|
---|
this.setForwardChannelRequestTimeout( timeoutMs ) → void
void
Sets the timeout for a forward channel request.
Parameters |
|
---|
this.setHandler( handler ) → void
void
Sets the handler used for channel callback events.
Parameters |
|
---|
this.setHttpHeadersOverwriteParam( httpHeadersOverwriteParam ) → void
void
Sets the URL param name to overwrite custom HTTP headers.
Parameters |
|
---|
this.setHttpSessionId( httpSessionId ) → void
void
Sets the http session id.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setHttpSessionIdParam( httpSessionIdParam ) → void
void
Sets the parameter name for the http session id.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
|
this.setInitHeaders( initHeaders ) → void
void
Sets extra HTTP headers to add to the init requests sent to the server.
Parameters |
|
---|
this.setReadyStateChangeThrottle( throttle ) → void
void
Sets the throttle for handling onreadystatechange events for the request.
Parameters |
|
---|
this.setRetryDelay( baseDelayMs, delaySeedMs ) → void
void
this.setSupportsCrossDomainXhrs( supportCrossDomain ) → void
void
Sets whether cross origin requests are supported for the channel.
Setting this allows the creation of requests to secondary domains and sends XHRs with the CORS withCredentials bit set to true.
In order for cross-origin requests to work, the server will also need to set CORS response headers as per: https://developer.mozilla.org/en-US/docs/HTTP_access_control
See goog.net.XhrIo#setWithCredentials
.
Parameters |
|
---|
this.shouldUseSecondaryDomains() → boolean
boolean
Determines whether to use a secondary domain when the server gives us a host prefix. This allows us to work around browser per-domain connection limits.
If you need to use secondary domains on different browsers and IE10,
you have two choices:
1) If you only care about browsers that support CORS
(https://developer.mozilla.org/en-US/docs/HTTP_access_control), you
can use #setSupportsCrossDomainXhrs
and set the appropriate
CORS response headers on the server.
2) Or, override this method in a subclass, and make sure that those
browsers use some messaging mechanism that works cross-domain (e.g
iframes and window.postMessage).
Specified by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.usesFetchStreams() → boolean
boolean
Whether or not this channel uses WHATWG Fetch/streams.
Specified by | ||
---|---|---|
Parameters | None. | |
Returns |
|
Static Properties
WebChannelBase.BACK_CHANNEL_MAX_RETRIES → number
number
Maximum number of attempts to connect to the server for back channel requests.
WebChannelBase.FORWARD_CHANNEL_RETRY_TIMEOUT → number
number
The timeout in milliseconds for a forward channel request.
WebChannelBase.INACTIVE_CHANNEL_RETRY_FACTOR → number
number
When retrying for an inactive channel, we will multiply the total delay by this number.
WebChannelBase.OUTSTANDING_DATA_BACKCHANNEL_RETRY_CUTOFF → number
number
A guess at a cutoff at which to no longer assume the backchannel is dead when we are slow to receive data. Number in bytes.
Assumption: The worst bandwidth we work on is 50 kilobits/sec 50kbits/sec * (1 byte / 8 bits) * 6 sec dead backchannel timeout
WebChannelBase.RTT_ESTIMATE → number
number
A number in MS of how long we guess the maxmium amount of time a round trip to the server should take. In the future this could be substituted with a real measurement of the RTT.