goog.messaging.AbstractChannel
Provided By | |
---|---|
Extends | |
All Implemented Interfaces | |
All Known Direct Subclasses |
Creates an abstract message channel.
new AbstractChannel()
Parameters | None. |
---|
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.connect( opt_connectCb ) → void
void
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
.
Specified by | |||||
---|---|---|---|---|---|
Parameters |
|
Converts the message payload into the format expected by the registered service (either JSON or string).
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.
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.getDisposed() → boolean
boolean
warning Deprecated | Use |
---|
Defined by | |||
---|---|---|---|
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.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
this.isConnected() → boolean
boolean
this.isDisposed() → boolean
boolean
Overrides | |||
---|---|---|---|
Specified by | |||
Parameters | None. | ||
Returns |
|
this.registerDefaultService( callback ) → void
void
Registers a service to be called when a message is received that doesn't match any other services.
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.
Specified by | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
this.send( serviceName, payload ) → void
void
Sends a message over the channel.
Specified by | |||||||||
---|---|---|---|---|---|---|---|---|---|
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.