Sending and receiving messages

The base functionality delivered by easyXDM is to, without any server-side dependencies,  pass string based messages between two domains in a fast, reliable and secure way.

With easyXDM this is easily done using the easyXDM.Socket class, a class that encapsulates the different transports and behaviors necessary to achieve speed, reliability and security.

To receive messages you simply set the onMessage method in the configuration

var socket = new easyXDM.Socket({
    onMessage: function(message, origin){

.. and to send messages you simply use the instantiated sockets .postMessage method

socket.postMessage("the string I want to send to the other end");

Remember, each Socket is bi-directional, so you only need to instantiate a single one per channel.
Take a look at the example here.

This entry was posted in Examples/How-to's and tagged , , , , , , . Bookmark the permalink.