
LocalConnection.domain() Method
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Alphabetical Language Reference
|
595
then defines its methods, then opens a connection named “channel3” (making displayMsg( )
eligible for remote execution):
receiveConn = new LocalConnection();
receiveConn.displayMsg = function (msg) {
output_txt.text += msg + "\n";
}
receiveConn.connect("channel3");
By checking the return value of connect( ), we can respond gracefully to connection attempt
failures. For example:
connectSuccess = receiveConn.connect("channel3");
if (connectSuccess) {
// ...proceed with application
} else {
// ...display failure screen
}
When connectionName does not start with an underscore (_), the name specified is auto-
matically prefixed with
receiveConn’s subdomain and a colon (e.g., “channel3” becomes
“oreilly.com:channel3” if the movie is posted at www.oreilly.com). When
connectionName
starts with an underscore, no prefix is applied.
Senders invoking remote methods on
receiveConn must match the final connection name
(automatic prefix +
connectionName) when invoking send( ). See LocalConnection.
allowDomain( ) and LocalConnection.send( ) for a discussion of connection name matching.
A LocalConnection object can maintain only one open connection at a time and cannot
open a connection with a connection name that is already in use. To close