The goog.messaging.MessageChannel Interface

goog.messaging.MessageChannel()

unhandled information:

type
'interface'

.connect(opt_connectCb)

Initiates the channel connection. When this method is called, all the information needed to connect the channel has to be available. Implementers should only require this method to be called if the channel needs to be configured in some way between when it's created and when it becomes active. Otherwise, the channel should be immediately active and this method should do nothing but immediately call opt_connectCb.

opt_connectCb {Function=}
Called when the channel has been connected and is ready to use.

.isConnected()

Gets whether the channel is connected. If {@link #connect} is not required for this class, this should always return true. Otherwise, this should return true by the time the callback passed to {@link #connect} has been called and always after that.

returns {boolean}
Whether the channel is connected.

.registerDefaultService(callback)

Registers a service to be called when a message is received that doesn't match any other services.

callback {function(string, (string|!Object))}
The callback to process the incoming messages. Passed the service name and the payload. Since some channels can pass objects natively, the payload may be either an object or a string.

.registerService(serviceName, callback, opt_objectPayload)

Registers a service to be called when a message is received. Implementers shouldn't impose any restrictions on the service names that may be registered. If some services are needed as control codes, {@link goog.messaging.MultiMessageChannel} can be used to safely split the channel into "public" and "control" virtual channels.

serviceName {string}
The name of the service.
callback {function((string|!Object))}
The callback to process the incoming messages. Passed the payload. If opt_objectPayload is set, the payload is decoded and passed as an object.
opt_objectPayload {boolean=}
If true, incoming messages for this service are expected to contain an object, and will be deserialized from a string automatically if necessary. It's the responsibility of implementors of this class to perform the deserialization.

.send(serviceName, payload)

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. It's the responsibility of implementors of this class to perform the serialization.