The goog.messaging.RespondingChannel Class

goog.messaging.RespondingChannel
> goog.Disposable

goog.messaging.RespondingChannel(messageChannel)

Creates a new RespondingChannel wrapping a single MessageChannel.

messageChannel {goog.messaging.MessageChannel}
The messageChannel to to wrap and allow for responses. This channel must not have any existing services registered. All service registration must be done through the {@link RespondingChannel#registerService} api instead. The other end of channel must also be a RespondingChannel.

.addOnDisposeCallback(callback, opt_scope)

Inherited from goog.Disposable .

Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.

callback {!Function}
The callback function.
opt_scope {Object=}
An optional scope to call the callback in.

.creationStack {string}

Inherited from goog.Disposable .

If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.

.dispose()

Inherited from goog.Disposable .

Disposes of the object. If the object hasn't already been disposed of, calls {@link #disposeInternal}. Classes that extend {@code goog.Disposable} should override {@link #disposeInternal} in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.

returns {void}
Nothing.

.isDisposed()

Inherited from goog.Disposable .

returns {boolean}
Whether the object has been disposed of.

.registerDisposable(disposable)

Inherited from goog.Disposable .

Associates a disposable object with this object so that they will be disposed together.

disposable {goog.disposable.IDisposable}
that will be disposed when this object is disposed.

.registerService(serviceName, callback)

Registers a service to be called when a message is received.

serviceName {string}
The name of the service.
callback {function(!Object)}
The callback to process the incoming messages. Passed the payload.

.send(serviceName, payload, callback)

Sends a message over the channel.

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 a string before sending if necessary.
callback {function(?Object)}
The callback invoked with the result of the service call.