messaging.BufferedChannel Extends goog.Disposable
Creates a new BufferedChannel, which operates like its underlying channel except that it buffers calls to send until it receives a message from its peer claiming that the peer is ready to receive. The peer is also expected to be a BufferedChannel, though this is not enforced.

Inheritance

Constructor

goog.messaging.BufferedChannel(messageChannelopt_interval)

Parameters

messageChannel : !goog.messaging.MessageChannel
The MessageChannel we're wrapping.
opt_interval : number=
Polling interval for sending ready notifications to peer, in ms. Default is 50.

Instance Methods

Public Protected Private
connect()
No description.
code »
disposeInternal()
No description.
code »
isConnected()
No description.
code »
isPeerReady() boolean
No description.
Returns: boolean  Whether the channel's peer is ready.
code »
registerDefaultService()
No description.
code »
registerService()
No description.
code »
send(serviceNamepayload)
Send a message over the channel. If the peer is not ready, the message will be buffered and sent once we've received a ready message from our peer.
Arguments:
serviceName : string
The name of the service this message should be delivered to.
payload : string | !Object
The value of the message. If this is an Object, it is serialized to JSON before sending. It's the responsibility of implementors of this class to perform the serialization.
code »
sendReadyPing_()
Handles one tick of our peer ready notification loop. This entails sending a ready ping to the peer and shutting down the loop if we've received a ping ourselves.
code »
setPeerReady_(peerKnowsWeKnowItsReady)
Marks the channel's peer as ready, then sends buffered messages and nulls the buffer. Subsequent calls to setPeerReady_ have no effect.
Arguments:
peerKnowsWeKnowItsReady : (!Object | string)
Passed by the peer to indicate whether it knows that we've received its ping and that it's ready. Non-empty if true, empty if false.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

buffer_ :
Buffer of messages to be sent when the channel's peer is ready.
Code »
constructor :
No description.
Code »
Virtual channel for carrying control messages for BufferedChannel.
Code »
logger_ : goog.debug.Logger
Logger.
Code »
multiChannel_ : goog.messaging.MultiChannel
Channel dispatcher wrapping the underlying delegate channel.
Code »
peerReady_ :
Whether or not the peer channel is ready to receive messages.
Code »
timer_ : goog.Timer
Timer for the peer ready ping loop.
Code »
Virtual channel for carrying the user's messages.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Properties

goog.messaging.BufferedChannel.CONTROL_CHANNEL_NAME_ :
The name of the virtual channel along which internal control messages are sent.
Code »
goog.messaging.BufferedChannel.DEFAULT_INTERVAL_MILLIS_ :
Default polling interval (in ms) for setPeerReady_ notifications.
Code »
goog.messaging.BufferedChannel.PEER_READY_SERVICE_NAME_ :
The name of the private service which handles peer ready pings. The service registered with this name is bound to this.setPeerReady_, an internal part of BufferedChannel's implementation that clients should not send to directly.
Code »
goog.messaging.BufferedChannel.USER_CHANNEL_NAME_ :
The name of the virtual channel along which user messages are sent.
Code »
goog.messaging.BufferedChannel.superClass_ :
No description.
Code »

Package messaging

Package Reference