postmessage-plus
Simple postmessage library. Provides a common API for interacting the window.postMessage and security against listening to dangerous messages.
Generally, window communications take the form of a client/server interaction. The client
window sends messages to the server. The server
listens to one or more client's messages.
postmessage-plus supports client-server as well as client-client interactions.
How to use
Here is a standard setup
Server
// Create an instancevar pm = listenDomain: 'http://clientDomain.com' // string, array or regex; // Listen to a channelpm;
Client
// Create an instancevar pm = sendDomain: 'http://serverDomain.com' // only string allowed, default that can be changed on individual messages; // Send a messagepm;
A single window can be both a server and a client. To send and receive messages, use sendDomain and listenDomain.