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.QueuedMap
Simple container class for a (mapId, map) pair.
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
goog.net.BrowserChannel.Handler
Interface for the browser channel handler

Public Protected Private

Global Functions

goog.net.BrowserChannel.LogSaver.addLogRecord(logRecord)
Adds a log record.
Arguments:
logRecord :
the LogRecord.
code »
goog.net.BrowserChannel.LogSaver.clearBuffer()
No description.
code »
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=
The session id for the channel.
opt_requestId :
string | number=
The request id for this request.
opt_retryId :
number=
The retry id for this request.
Returns:   The created channel request.
code »
goog.net.BrowserChannel.endExecutionHook_()
No description.
code »
goog.net.BrowserChannel.LogSaver.getBuffer()
Returns the log as a single string.
Returns:   The log as a single string.
code »
goog.net.BrowserChannel.getStatEventTarget()
Returns the singleton event target for stat events.
Returns:   The event target for stat events.
code »
goog.net.BrowserChannel.LogSaver.isEnabled()
Returns whether the LogSaver is enabled.
Returns:   Whether saving is enabled or disabled.
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
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
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()
No description.
code »
goog.net.BrowserChannel.onStartExecution()
No description.
code »
goog.net.BrowserChannel.LogSaver.setEnabled(enable)
Enables of disables the LogSaver.
Arguments:
enable :
Whether to enable or disable saving.
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 :
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 :
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 :
The callback function.
ms :
The time in MS for the timer.
Returns:   The ID of the timer.
code »
goog.net.BrowserChannel.startExecutionHook_()
No description.
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 :
Events fired by BrowserChannel and associated objects
Code »
goog.net.BrowserChannel.FORWARD_CHANNEL_MAX_RETRIES :
Maximum number of attempts to connect to the server for forward channel requests.
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.RETRY_DELAY_MS :
Default timeout in MS before the initial retry. Subsequent retries will be slower.
Code »
goog.net.BrowserChannel.RETRY_DELAY_SEED :
We will add a random time between 0 and this number of MS to retries to the retry time for this request.
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.LogSaver.buffer_ :
Buffer for accumulating the debug log
Code »
goog.net.BrowserChannel.LogSaver.enabled_ :
Whether we're currently accumulating the debug log.
Code »
goog.net.BrowserChannel.LogSaver.formatter_ :
Formatter for saving logs.
Code »
goog.net.BrowserChannel.statEventTarget_ :
Singleton event target for firing stat events
Code »

Directory net

File Reference