Adding easyXDM to your project, including debugging tools

To be able to use easyXDM in you project, either as a provider, consumer or both, there are a few things that you need to do.

easyXDM ships with three versions of the core library, a readable production version, a minified production version, and a debug version that includes advanced tracing capabilities.

As you have probably seen, all the examples referenced on these pages display a trace of whats going on, either in the browsers console (if supported), or in a dynamic popup window. This makes it very easy to debug the setup if something were to go wrong.

Note: The popup is not present in the production build, it is only there to facilitate tracing.

Including the Javascript-files

With modern browsers that support the postMessage interface, and IE6/7 you need nothing more than to include the library in your document, but to properly be able to support other browsers you need to place a special html file, called name.html on the servers. With this file present easyXDM is able to use the fast NameTransport, but if not, then it will have to fall back to using the HashTransport

So, basically what it comes down to is including the following in the header of your document

<script type="text/javascript" src="/easyXDM/easyXDM.debug.js"></script>

And of course, once you are ready for production you replace .debug.js with .min.js.

Including support for the JSON-object

If you plan on using the Rpc class, or need access to the JSON object (for serializing JSON objects) then you should also upload Douglas Crockfords json2 library to the server and place this code immediately after the previous script tag

<script type="text/javascript">
    easyXDM.DomHelper.requiresJSON("/json2.js");
</script>

If the browser supports JSON natively, then this code will do nothing, but if not, then it will output a script tag pointing to the json2.js script directly after.

It is important that no code that depends on the JSON object is placed in this script block as the object wont be available until AFTER the script block, and the generated one has been parsed and executed.

This entry was posted in Getting started and tagged , , , , , , , , , , . Bookmark the permalink.