labs.net.webChannel.WebChannelBase Extends
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.

Inheritance

Constructor

goog.labs.net.webChannel.WebChannelBase(opt_optionsopt_clientVersionopt_conn)

Parameters

opt_options : !goog.net.WebChannel.Options=
Configuration for the WebChannel instance.
opt_clientVersion : string=
An application-specific version number that is sent to the server when connected.
opt_conn : !ConnectionState=
Previously determined connection conditions.

Instance Methods

Public Protected Private
addAdditionalParams_(uri)
Adds the additional parameters from the handler to the given URI.
Arguments:
uri : !goog.Uri
The URI to add the parameters to.
code »
cancelRequests_()
Cancels all outstanding requests.
code »
clearDeadBackchannelTimer_()
Clears the timer that indicates that our backchannel is no longer able to successfully receive data from the server.
code »
connect(testPathchannelPathopt_extraParamsopt_oldSessionIdopt_oldArrayId)
Starts the channel. This initiates connections to the server.
Arguments:
testPath : string
The path for the test connection.
channelPath : string
The path for the channel connection.
opt_extraParams : !Object=
Extra parameter keys and values to add to the requests.
opt_oldSessionId : string=
Session ID from a previous session.
opt_oldArrayId : number=
The last array ID from a previous session.
code »
connectChannel_()
Starts the regular channel which is run after the test channel is complete.
code »
connectTest_(testPath)
Starts the test channel to determine network conditions.
Arguments:
testPath : string
The relative PATH for the test connection.
code »
correctHostPrefix(serverHostPrefix) ?string
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.
Arguments:
serverHostPrefix : ?string
The host prefix provided by the server.
Returns: ?string  The host prefix to actually use, if any. Will return null if the use of host prefixes was disabled via setAllowHostPrefix().
code »
createDataUri()
No description.
code »
createXhrIo()
No description.
code »
dequeueOutgoingMaps_() string
Returns the request text from the outgoing maps and resets it.
Returns: string  The encoded request text created from all the currently queued outgoing maps.
code »
disconnect()
Disconnects and closes the channel.
code »
ensureBackChannel_()
Ensures there is a backchannel request for receiving data from the server.
code »
ensureForwardChannel_()
Ensures that a forward channel request is scheduled.
code »
ensureInState_(var_args)
Helper to ensure the channel is in the expected state.
Arguments:
var_args : ...number
The channel must be in one of the indicated states.
code »
getAllowChunkedMode()
Returns whether chunked mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable chunked mode for a user. @return {boolean} Whether chunked mode is allowed.
code »
getAllowHostPrefix() boolean
Returns whether the channel allows the use of a subdomain. There may be cases where this isn't allowed.
Returns: boolean  Whether a host prefix is allowed.
code »
getBackChannelMaxRetries() number
No description.
Returns: number  The max number of back-channel retries, which is a constant.
code »
getBackChannelUri()
No description.
code »
getChannelDebug() !WebChannelDebug
Returns the logger.
Returns: !WebChannelDebug  The channel debug object.
code »
getConnectionState()
No description.
code »
getExtraHeaders() Object
Returns the extra HTTP headers to add to all the requests sent to the server.
Returns: Object  The HTTP headers, or null.
code »
getForwardChannelMaxRetries() number
No description.
Returns: number  The max number of forward-channel retries, which will be 0 in fail-fast mode.
code »
getForwardChannelRequestPool() !ForwardChannelRequestPool
No description.
Returns: !ForwardChannelRequestPool  The forward channel request pool.
code »
getForwardChannelUri()
No description.
code »
getHandler() WebChannelBase.Handler
Returns the handler used for channel callback events.
Returns: WebChannelBase.Handler  The handler.
code »
getLastArrayId() number
No description.
Returns: number  The last array id received.
code »
getLastStatusCode() number
Return the last status code received for a request.
Returns: number  The last status code received for a request.
code »
getOutstandingRequests_() number
Returns the number of outstanding requests.
Returns: number  The number of outstanding requests to the server.
code »
getRetryTime_(retryCount) number
No description.
Arguments:
retryCount : number
Number of retries so far.
Returns: number  Time in ms before firing next retry request.
code »
getSessionId() string
Returns the session id of the channel. Only available after the channel has been opened.
Returns: string  Session ID.
code »
getState() WebChannelBase.State
Returns the channel state.
Returns: WebChannelBase.State  The current state of the channel.
code »
getWireCodec() !Object
No description.
Returns: !Object  The codec object, to be used for the test channel.
code »
handleBackchannelMissing_(forwardReq)
Handles a POST response from the server telling us that it has detected that we have no hanging GET connection.
Arguments:
forwardReq : !ChannelRequest
The forward channel request that triggers this function call.
code »
handlePostResponse_(responseValuesforwardReq)
Handles a POST response from the server.
Arguments:
responseValues : Array
The key value pairs in the POST response.
forwardReq : !ChannelRequest
The forward channel request that triggers this function call.
code »
hasOutstandingRequests() boolean
Returns whether there are outstanding requests servicing the channel.
Returns: boolean  true if there are outstanding requests.
code »
isActive()
No description.
code »
isBuffered() boolean
Returns whether the channel is buffered or not. This state is valid for querying only after the test connection has completed. This may be queried in the WebChannelBase.okToMakeRequest() callback. A channel may be buffered if the test connection determines that a chunked response could not be sent down within a suitable time.
Returns: boolean  Whether the channel is buffered.
code »
isClosed()
No description.
code »
makeForwardChannelRequest_(opt_retryRequest)
Makes a forward channel request using XMLHTTP.
Arguments:
opt_retryRequest : !ChannelRequest=
A failed request to retry.
code »
maybeRetryBackChannel_() boolean
Schedules a back-channel retry, unless the max retries has been reached.
Returns: boolean  true iff a retry was scheduled.
code »
maybeRetryForwardChannel_(request) boolean
Schedules a forward-channel retry for the specified request, unless the max retries has been reached.
Arguments:
request : ChannelRequest
The failed request to retry.
Returns: boolean  true iff a retry was scheduled.
code »
okToMakeRequest_() boolean
Gives the handler a chance to return an error code and stop channel execution. A handler might want to do this to check that the user is still logged in, for example.
Returns: boolean  If it's OK to make a request.
code »
onBackChannelDead_()
Handles the timer that indicates that our backchannel is no longer able to successfully receive data from the server.
code »
onClose_()
Called when the channel has been closed. It notifiers the handler of the event, and reports any pending or undelivered maps.
code »
onError_(error)
Called when we've determined the final error for a channel. It closes the notifiers the handler of the error and closes the channel.
Arguments:
error : WebChannelBase.Error
The error code for the failure.
code »
onInput_(respArray)
Processes the data returned by the server.
Arguments:
respArray : !Array.<!Array>
The response array returned by the server.
code »
onRequestComplete()
No description.
code »
onRequestData()
No description.
code »
onStartBackChannelTimer_()
Timer callback for ensureBackChannel_.
code »
onStartForwardChannelTimer_(opt_retryRequest)
Timer callback for ensureForwardChannel
Arguments:
opt_retryRequest : ChannelRequest=
A failed request to retry.
code »
onSuccess_()
Called when messages have been successfully sent from the queue.
code »
open_()
Establishes a new channel session with the the server.
code »
requeuePendingMaps_()
Requeues unacknowledged sent arrays for retransmission in the next forward channel request.
code »
sendMap(mapopt_context)
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.
Arguments:
map : !Object | !goog.structs.Map
The map to send.
opt_context : !Object=
The context associated with the map.
code »
setAllowChunkedMode(allowChunkedMode)
Sets whether chunked mode is allowed. In certain debugging situations, it's useful for the application to have a way to disable chunked mode for a user.
Arguments:
allowChunkedMode : boolean
Whether chunked mode is allowed.
code »
setAllowHostPrefix(allowHostPrefix)
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.
Arguments:
allowHostPrefix : boolean
Whether a host prefix is allowed.
code »
setChannelDebug(channelDebug)
Sets the logger.
Arguments:
channelDebug : !WebChannelDebug
The channel debug object.
code »
setExtraHeaders(extraHeaders)
Sets extra HTTP headers to add to all the requests sent to the server.
Arguments:
extraHeaders : Object
The HTTP headers, or null.
code »
setFailFast(failFast)
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.
Arguments:
failFast : boolean
Whether or not to fail fast.
code »
setForwardChannelMaxRetries(retries)
Sets the maximum number of attempts to connect to the server for forward channel requests.
Arguments:
retries : number
The maximum number of attempts.
code »
setForwardChannelRequestTimeout(timeoutMs)
Sets the timeout for a forward channel request.
Arguments:
timeoutMs : number
The timeout in milliseconds.
code »
setHandler(handler)
Sets the handler used for channel callback events.
Arguments:
handler : WebChannelBase.Handler
The handler to set.
code »
setReadyStateChangeThrottle(throttle)
Sets the throttle for handling onreadystatechange events for the request.
Arguments:
throttle : number
The throttle in ms. A value of zero indicates no throttle.
code »
setRetryDelay(baseDelayMsdelaySeedMs)
No description.
Arguments:
baseDelayMs : number
The base part of the retry delay, in ms.
delaySeedMs : number
A random delay between 0 and this is added to the base part.
code »
setSupportsCrossDomainXhrs(supportCrossDomain)
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.
Arguments:
supportCrossDomain : boolean
Whether cross domain XHRs are supported.
code »
shouldRetryBackChannel_(outstandingBytes) boolean
Determines whether we should start the process of retrying a possibly dead backchannel.
Arguments:
outstandingBytes : number
The number of bytes for which the server has not yet received acknowledgement.
Returns: boolean  Whether to start the backchannel retry timer.
code »
shouldUseSecondaryDomains()
No description.
code »
signalError_(error)
Signals an error has occurred.
Arguments:
error : WebChannelBase.Error
The error code for the failure.
code »
startBackChannel_()
Begins a new back channel operation to the server.
code »
startForwardChannel_(opt_retryRequest)
Begins a new forward channel operation to the server.
Arguments:
opt_retryRequest : ChannelRequest=
A failed request to retry.
code »
testConnectionFailure()
No description.
code »
testConnectionFinished()
No description.
code »
testNetworkCallback_(networkUp)
Callback for netUtils.testNetwork during error handling.
Arguments:
networkUp : boolean
Whether the network is up.
code »

Instance Properties

Previous connectivity test results.
Code »
allowChunkedMode_ :
Whether chunked mode is allowed. In certain debugging situations, it's useful to disable this.
Code »
allowHostPrefix_ :
Whether we allow the use of a subdomain in IE for the backchannel requests.
Code »
backChannelAttemptId_ :
The attempt id for the current back channel request. Starts at 1 and increments for each reconnect. The server uses this to log if our connection is flaky or not.
Code »
The ChannelRequest object for the backchannel.
Code »
backChannelRetryCount_ :
Number of times in a row that we have retried the current back channel request and received no data.
Code »
backChannelTimerId_ :
Timer identifier for asynchronously making a back channel request.
Code »
backChannelUri_ : goog.Uri
The absolute URI for the backchannel request.
Code »
baseRetryDelayMs_ :
The base part of the time before firing next retry request. Default is 5 seconds. Note that a random delay is added (see retryDelaySeedMs_) for all retries, and linear backoff is applied to the sum for subsequent retries.
Code »
The channel debug used for logging
Code »
channelVersion_ :
The channel version that we negotiated with the server for this session. Starts out as the version we request, and then is changed to the negotiated version after the initial open.
Code »
clientVersion_ :
The application specific version that is passed to the server.
Code »
The TestChannel object which encapsulates the logic for determining interesting network conditions about the client.
Code »
deadBackChannelTimerId_ :
Timer identifier for the timer that waits for us to retry the backchannel in the case where it is dead and no longer receiving data.
Code »
extraHeaders_ :
Extra HTTP headers to add to all the requests sent to the server.
Code »
extraParams_ :
Extra parameters to add to all the requests sent to the server.
Code »
failFast_ :
Whether to fail forward-channel requests after one try or a few tries.
Code »
forwardChannelMaxRetries_ :
Maximum number of attempts to connect to the server for forward channel requests. Defaults to 2.
Code »
The current ChannelRequest pool for the forward channel.
Code »
forwardChannelRequestTimeoutMs_ :
The timeout in milliseconds for a forward channel request. Defaults to 20 seconds. Note that part of this timeout can be randomized.
Code »
forwardChannelRetryCount_ :
Number of times we have retried the current forward channel request.
Code »
forwardChannelTimerId_ :
Timer identifier for asynchronously making a forward channel request.
Code »
forwardChannelUri_ : goog.Uri
The absolute URI for the forwardchannel request.
Code »
The handler that receive callbacks for state changes and data.
Code »
hostPrefix_ :
A subdomain prefix for using a subdomain in IE for the backchannel requests.
Code »
lastArrayId_ :
The array identifier of the last array received from the server for the backchannel request.
Code »
lastPostResponseArrayId_ :
The array id of the last array sent by the server that we know about.
Code »
lastStatusCode_ :
The last status code received.
Code »
nextMapId_ :
The id to use for the next outgoing map. This identifier uniquely identifies a sent map.
Code »
nextRid_ :
The next id to use for the RID (request identifier) parameter. This identifier uniquely identifies the forward channel request.
Code »
outgoingMaps_ :
An array of queued maps that need to be sent to the server.
Code »
path_ :
The relative path (in the context of the the page hosting the browser channel) for making requests to the server.
Code »
pendingMaps_ :
An array of dequeued maps that we have either received a non-successful response for, or no response at all, and which therefore may or may not have been received by the server.
Code »
readyStateChangeThrottleMs_ :
A throttle time in ms for readystatechange events for the backchannel. Useful for throttling when ready state is INTERACTIVE (partial data). This throttle is useful if the server sends large data chunks down the backchannel. It prevents examining XHR partial data on every readystate change event. This is useful because large chunks can trigger hundreds of readystatechange events, each of which takes ~5ms or so to handle, in turn making the UI unresponsive for a significant period. If set to zero no throttle is used.
Code »
retryDelaySeedMs_ :
A random time between 0 and this number of MS is added to the baseRetryDelayMs_. Default is 10 seconds.
Code »
sid_ :
The current session id.
Code »
state_ :
The current state of the WebChannel.
Code »
supportsCrossDomainXhrs_ :
Whether cross origin requests are supported for the channel. See goog.net.XhrIo#setWithCredentials.
Code »
useChunked_ :
Whether the client's network conditions can support chunked responses.
Code »
The V8 codec.
Code »

Static Methods

goog.labs.net.webChannel.WebChannelBase.isFatalError_(errorstatusCode) boolean
Returns whether or not the given error/status combination is fatal or not. On fatal errors we immediately close the session rather than retrying the failed request.
Arguments:
error : ?ChannelRequest.Error
The error code for the failed request.
statusCode : number
The last HTTP status code.
Returns: boolean  Whether or not the error is fatal.
code »

Static Properties

goog.labs.net.webChannel.WebChannelBase.BACK_CHANNEL_MAX_RETRIES :
Maximum number of attempts to connect to the server for back channel requests.
Code »
goog.labs.net.webChannel.WebChannelBase.FORWARD_CHANNEL_RETRY_TIMEOUT :
The timeout in milliseconds for a forward channel request.
Code »
goog.labs.net.webChannel.WebChannelBase.INACTIVE_CHANNEL_RETRY_FACTOR :
When retrying for an inactive channel, we will multiply the total delay by this number.
Code »
goog.labs.net.webChannel.WebChannelBase.LogSaver :
A LogSaver that can be used to accumulate all the debug logs so they can be sent to the server when a problem is detected.
Code »
goog.labs.net.webChannel.WebChannelBase.MAX_MAPS_PER_REQUEST_ :
The maximum number of maps that can be sent in one POST. Should match MAX_MAPS_PER_REQUEST on the server code.
Code »
goog.labs.net.webChannel.WebChannelBase.OUTSTANDING_DATA_BACKCHANNEL_RETRY_CUTOFF :
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
Code »
goog.labs.net.webChannel.WebChannelBase.RTT_ESTIMATE :
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.
Code »

Enumerations

goog.labs.net.webChannel.WebChannelBase.ChannelType_ :
Internal enum type for the two channel types.
Constants:
BACK_CHANNEL
No description.
FORWARD_CHANNEL
No description.
Code »
goog.labs.net.webChannel.WebChannelBase.Error :
Enum type for identifying an error.
Constants:
ACTIVE_X_BLOCKED
No description.
BAD_DATA
No description.
BAD_RESPONSE
No description.
LOGGED_OUT
No description.
NETWORK
No description.
NO_DATA
No description.
OK
No description.
REQUEST_FAILED
No description.
STOP
No description.
UNKNOWN_SESSION_ID
No description.
Code »
goog.labs.net.webChannel.WebChannelBase.State :
Enum type for the channel state machine.
Constants:
CLOSED
No description.
INIT
No description.
OPENED
No description.
OPENING
No description.
Code »

Package labs.net.webChannel

Package Reference