browserchannel.js
Definition of the BrowserChannel class. A BrowserChannel simulates a bidirectional socket over HTTP. It is the basis of the Gmail Chat IM connections to the server. See http://wiki/Main/BrowserChannel This doesn't yet completely comform to the design document as we've done some renaming and cleanup in the design document that hasn't yet been implemented in the protocol. Typical usage will look like var handler = [handler object]; var channel = new BrowserChannel(clientVersion); channel.setHandler(handler); channel.connect('channel/test', 'channel/bind'); See goog.net.BrowserChannel.Handler for the handler interface.

File Location

net/browserchannel.js

Classes

goog.net.BrowserChannel
Encapsulates the logic for a single BrowserChannel.
goog.net.BrowserChannel.Handler
Interface for the browser channel handler
goog.net.BrowserChannel.QueuedMap
Simple container class for a (mapId, map) pair.
goog.net.BrowserChannel.ServerReachabilityEvent
Event class for goog.net.BrowserChannel.Event.SERVER_REACHABILITY_EVENT.
goog.net.BrowserChannel.StatEvent
Event class for goog.net.BrowserChannel.Event.STAT_EVENT
goog.net.BrowserChannel.TimingEvent
Event class for goog.net.BrowserChannel.Event.TIMING_EVENT

Public Protected Private

Enumerations

Global Functions

goog.net.BrowserChannel.createChannelRequest(channelchannelDebugopt_sessionIdopt_requestIdopt_retryId)
Instantiates a ChannelRequest with the given parameters. Overidden in tests.
Arguments:
channel :
The BrowserChannel that owns this request.
channelDebug :
A ChannelDebug to use for logging.
opt_sessionId :
(string | undefined)
The session id for the channel.
opt_requestId :
(number | string | undefined)
The request id for this request.
opt_retryId :
(number | undefined)
The retry id for this request.
Returns:   The created channel request.
code »
goog.net.BrowserChannel.getStatEventTarget()
Returns the singleton event target for stat events.
Returns:   The event target for stat events.
code »
goog.net.BrowserChannel.isFatalError_(errorstatusCode)
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 :
(goog.net.ChannelRequest.Error.<number> | null)
The error code for the failed request.
statusCode :
The last HTTP status code.
Returns:   Whether or not the error is fatal.
code »
goog.net.BrowserChannel.notifyStatEvent(stat)
Helper function to call the stat event callback.
Arguments:
stat :
goog.net.BrowserChannel.Stat.<number>
The stat.
code »
goog.net.BrowserChannel.notifyTimingEvent(sizerttretries)
Helper function to notify listeners about POST request performance.
Arguments:
size :
Number of characters in the POST data.
rtt :
The amount of time from POST start to response.
retries :
The number of times the POST had to be retried.
code »
goog.net.BrowserChannel.onEndExecution()
Helper function to call the end hook
code »
goog.net.BrowserChannel.onStartExecution()
Helper function to call the start hook
code »
goog.net.BrowserChannel.setEndThreadExecutionHook(endHook)
Allows the application to set an execution hooks for when BrowserChannel stops processing requests. This is useful to track timing or logging special information. The function takes no parameters and return void.
Arguments:
endHook :
(Function | null)
The function for the end hook.
code »
goog.net.BrowserChannel.setStartThreadExecutionHook(startHook)
Allows the application to set an execution hooks for when BrowserChannel starts processing requests. This is useful to track timing or logging special information. The function takes no parameters and return void.
Arguments:
startHook :
(Function | null)
The function for the start hook.
code »
goog.net.BrowserChannel.setTimeout(fnms)
Wrapper around SafeTimeout which calls the start and end execution hooks with a try...finally block.
Arguments:
fn :
(Function | null)
The callback function.
ms :
The time in MS for the timer.
Returns:   The ID of the timer.
code »

Global Properties

goog.net.BrowserChannel.BACK_CHANNEL_MAX_RETRIES :
Maximum number of attempts to connect to the server for back channel requests.
Code »
goog.net.BrowserChannel.Event :
(Object | null)
Events fired by BrowserChannel and associated objects
Code »
goog.net.BrowserChannel.FORWARD_CHANNEL_RETRY_TIMEOUT :
The timeout in milliseconds for a forward channel request.
Code »
goog.net.BrowserChannel.INACTIVE_CHANNEL_RETRY_FACTOR :
When retrying for an inactive channel, we will multiply the total delay by this number.
Code »
goog.net.BrowserChannel.LATEST_CHANNEL_VERSION :
The latest protocol version that this class supports. We request this version from the server when opening the connection. Should match com.google.net.browserchannel.BrowserChannel.LATEST_CHANNEL_VERSION.
Code »
goog.net.BrowserChannel.MAGIC_RESPONSE_COOKIE :
The normal response for forward channel requests. Used only before version 8 of the protocol.
Code »
goog.net.BrowserChannel.MAX_MAPS_PER_REQUEST_ :
The maximum number of maps that can be sent in one POST. Should match com.google.net.browserchannel.BrowserChannel.MAX_MAPS_PER_REQUEST.
Code »
goog.net.BrowserChannel.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.net.BrowserChannel.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 »
goog.net.BrowserChannel.endExecutionHook_ :
(Function | null)
Application provided execution hook for the end hook.
Code »
goog.net.BrowserChannel.startExecutionHook_ :
(Function | null)
Application provided execution hook for the start hook.
Code »
goog.net.BrowserChannel.statEventTarget_ :
Singleton event target for firing stat events
Code »

Directory net

File Reference