MessagePort
s and WebWorker
s). This class implements the
goog.messaging.MessageChannel
interface.
This class can be used in conjunction with other communication on the port.
It sets goog.messaging.PortChannel.FLAG
to true on all messages it
sends.
goog.Disposable | |
goog.messaging.AbstractChannel | goog.Disposable |
goog.messaging.PortChannel | goog.messaging.AbstractChannel |
underlyingPort
: !MessagePort | !WebWorker
The message-passing
entity to wrap. If this is a
MessagePort , it should be started.
The remote end should also be wrapped in a PortChannel. This will be
disposed along with the PortChannel; this means terminating it if it's a
worker or removing it from the DOM if it's an iframe. |
![]()
Delivers a message to the appropriate service handler. If this message isn't
a GearsWorkerChannel message, it's ignored and passed on to other handlers.
Arguments:
|
code » | ||
![]()
No description.
|
code » | ||
Extracts all MessagePort objects from a message to be sent into an array.
The message ports are replaced by placeholder objects that will be replaced
with the ports again on the other side of the channel.
|
code » | ||
Injects MessagePorts back into a message received from across the channel.
|
code » | ||
![]()
Sends a message over the channel.
As an addition to the basic MessageChannel send API, PortChannels can send
objects that contain MessagePorts. Note that only plain Objects and Arrays,
not their subclasses, can contain MessagePorts.
As per
http://www.w3.org/TR/html5/comms.html#clone-a-port , once a
port is copied to be sent across a channel, the original port will cease
being able to send or receive messages.
|
code » | ||
Checks whether the message is invalid in some way.
|
code » |
![]()
Immediately calls opt_connectCb if given, and is otherwise a no-op. If
subclasses have configuration that needs to happen before the channel is
connected, they should override this and
#isConnected .
|
code » | |
Converts the message payload into the format expected by the registered
service (either JSON or string).
|
code » | |
![]()
The default service to be run when no other services match.
|
code » | |
![]()
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.
|
code » | |
![]()
No description.
|
code » | |
![]()
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.
|
code » | |
![]()
Always returns true. If subclasses have configuration that needs to happen
before the channel is connected, they should override this and
#connect .
|
code » | |
![]()
No description.
|
code » | |
![]()
No description.
|
code » |
![]()
Invokes a callback function when this object is disposed. Callbacks are
invoked in the order in which they were added.
Arguments:
|
code » | |||
![]()
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 » | |||
![]()
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 » | |||
Use
#isDisposed instead.
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
No description.
Returns: boolean
Whether the object has been disposed of.
|
code » | |||
![]()
Associates a disposable object with this object so that they will be disposed
together.
Arguments:
|
code » |
![]()
Create a PortChannel that communicates with a window embedded in the current
page (e.g. an iframe contentWindow). The code within the window should call
forGlobalWindow to establish the connection.
It's possible to use this channel in conjunction with other messages to the
embedded window. However, only one PortChannel should be used for a given
window at a time.
Arguments:
Returns: !goog.messaging.DeferredChannel
The PortChannel. Although this is
not actually an instance of the PortChannel class, it will behave like
one in that MessagePorts may be sent across it. The DeferredChannel may
be cancelled before a connection is established in order to abort the
attempt to make a connection.
|
code » | ||||
Create a PortChannel that communicates with the document in which this window
is embedded (e.g. within an iframe). The enclosing document should call
forEmbeddedWindow to establish the connection.
It's possible to use this channel in conjunction with other messages posted
to the global window. However, only one PortChannel should be used for the
global window at a time.
Arguments:
Returns: !goog.messaging.MessageChannel
The PortChannel. Although this may
not actually be an instance of the PortChannel class, it will behave like
one in that MessagePorts may be sent across it.
|
code » |
![]()
The flag added to messages that are sent by a PortChannel, and are meant to
be handled by one on the other side.
|
Code » | |
![]()
Whether the messages sent across the channel must be JSON-serialized. This is
required for older versions of Webkit, which can only send string messages.
Although Safari and Chrome have separate implementations of message passing,
both of them support passing objects by Webkit 533.
|
Code » | |
![]()
No description.
|
Code » |