17.4. Accepting Communications from Other Domains
Problem
You want a movie to accept local connection communications from movies served from other domains.
Solution
Use the allowDomain( ) method of the receiving
local connection object.
Discussion
By default, receiving movies accept communications from sending
movies on the same domain only. However, you can use the
allowDomain( ) method of a local connection
object to allow or disallow communications from any domains. You need
to define the allowDomain( ) method for each
receiving local connection object for which you wish to define a
custom list of domains to accept or deny.
If present, the allowDomain( ) method is
automatically invoked when a local connection object receives a
communication. If allowDomain( ) returns
true, the communication is accepted; if it returns
false, the communication is denied. Therefore, you
can configure a local connection object to receive communications
from any domain by having its allowDomain( )
method return true in all cases:
// Define the receiving local connection, and instruct it to listen to communications // over the"_myConnection"channel. receiving_lc = new LocalConnection( ); receiving_lc.connect("_myConnection"); // Define theallowDomain( )method for the receiving local connection object, which // is invoked automatically whenever a communication is received. This example always // returnstrue, so all communications are accepted. receiving_lc.allowDomain = function (domain) { return true; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access