goog.net.xpc.CrossPageChannel
Provided By | |
---|---|
Extends | |
All Implemented Interfaces |
warning Deprecated | Prefer goog.messaging.MessageChannel and friends. |
---|
A communication channel between two documents from different domains. Provides asynchronous messaging.
new CrossPageChannel( cfg, opt_domHelper )
Parameters |
|
---|
Instance Methods
this.addOnDisposeCallback<T>( callback, opt_scope ) → void
void
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added. If a callback is added to an already disposed Disposable, it will be called immediately.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.close() → void
void
Closes the channel.
this.connect( opt_connectCb ) → void
void
Initiates connecting the channel. When this method is called, all the information needed to connect the channel has to be available.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
|
this.createPeerIframe( parentElm, opt_configureIframeCb, opt_addCfgParam ) → HTMLIFrameElement
HTMLIFrameElement
Creates the iframe containing the peer page in a specified parent element. This method does not connect the channel, connect() still has to be called separately.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Converts the message payload into the format expected by the registered service (either JSON or string).
Defined by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||||||
Returns |
|
this.deliver( serviceName, payload ) → void
void
Delivers a message to the appropriate service. This is meant to be called by subclasses when they receive messages.
This method takes into account both explicitly-registered and default services, as well as making sure that JSON payloads are decoded when necessary. If the subclass is capable of passing objects as payloads, those objects can be passed in to this method directly. Otherwise, the (potentially JSON-encoded) strings should be passed in.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.dispose() → ?
?
Disposes of the object and its resources.
Overrides | ||
---|---|---|
Specified by | ||
Parameters | None. | |
Returns |
|
this.disposeInternal() → void
void
Performs appropriate cleanup. See description of goog.disposable.IDisposable
for examples. 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'); };
Overrides | |
---|---|
Parameters | None. |
this.getConfig() → (Object|null)
(Object|null)
Returns the configuration object for this channel. Package private. Do not call from outside goog.net.xpc.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.getIframeElement() → (HTMLIFrameElement|null)
(HTMLIFrameElement|null)
Returns a reference to the iframe-element. Package private. Do not call from outside goog.net.xpc.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPeerConfiguration() → Object
Object
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPeerUri( opt_addCfgParam ) → goog.Uri
goog.Uri
this.getPeerWindowObject() → (Object|null)
(Object|null)
Returns the window object the foreign document resides in.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getRole() → number
number
Returns the role of this channel (either inner or outer).
Parameters | None. | ||
---|---|---|---|
Returns |
|
Find the service object for a given service name. If there's no service explicitly registered, but there is a default service, a service object is constructed for it.
Defined by | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
| ||||||||
Returns |
|
this.getTransportName() → string
string
Returns the tranport name in use for this channel.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getTransportType() → number
number
Returns the transport type in use for this channel.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isConnected() → boolean
boolean
Gets whether the channel is connected.
If #connect
is not required for this class, this should always return
true. Otherwise, this should return true by the time the callback passed to
#connect
has been called and always after that.
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.isMessageOriginAcceptable( opt_origin ) → boolean
boolean
Returns whether an incoming message with the given origin is acceptable. If an incoming request comes with a specified (non-empty) origin, and the PEER_HOSTNAME config parameter has also been provided, the two must match, or the message is unacceptable.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.isPeerAvailable() → boolean
boolean
Determines whether the peer window is available (e.g. not closed).
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.notifyConnected( opt_delay ) → void
void
Package-private. Called by the transport when the channel is connected.
Parameters |
|
---|
this.notifyTransportError() → void
void
Called by the transport in case of an unrecoverable failure. Package private. Do not call from outside goog.net.xpc.
this.registerDefaultService( callback ) → void
void
Registers a service to be called when a message is received that doesn't match any other services.
Overrides | |||||
---|---|---|---|---|---|
Specified by | |||||
Parameters |
|
this.registerDisposable( disposable ) → void
void
Associates a disposable object with this object so that they will be disposed together.
Defined by | |||||
---|---|---|---|---|---|
Parameters |
|
this.registerService( serviceName, callback, opt_objectPayload ) → void
void
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,
goog.messaging.MultiMessageChannel
can be used to safely split the
channel into "public" and "control" virtual channels.
Overrides | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||||||
Parameters |
|
this.send( serviceName, payload ) → void
void
Sends a message over the channel.
Overrides | |||||||||
---|---|---|---|---|---|---|---|---|---|
Specified by | |||||||||
Parameters |
|
this.setPeerWindowObject( peerWindowObject ) → void
void
Sets the window object the foreign document resides in.
Parameters |
|
---|
this.updateChannelNameAndCatalog( name ) → void
void
Sets the channel name. Note, this doesn't establish a unique channel to communicate on.
Parameters |
|
---|
this.xpcDeliver( serviceName, payload, opt_origin ) → void
void
Delivers messages to the appropriate service-handler. Named xpcDeliver to
avoid name conflict with deliver
function in superclass
goog.messaging.AbstractChannel.
Parameters |
|
---|
Instance Properties
this.creationStack → (string|undefined)
(string|undefined)
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
this.logger → (goog.log.Logger|null)
(goog.log.Logger|null)
Logger for this class.
this.name → string
string
The name of the channel. Please use
updateChannelNameAndCatalog
to change this from the transports
vs changing the property directly.
Static Properties
CrossPageChannel.channels → Object<string, goog.net.xpc.CrossPageChannel>
Object<string, goog.net.xpc.CrossPageChannel>
Object holding active channels.