BlazeDS Developer Guide

Ajax client library API reference

The Ajax client library is a set of JavaScript APIs that lets Ajax developers access the messaging capabilities of BlazeDS directly from JavaScript.

AsyncResponder

JavaScript proxy to the ActionScript AsyncResponder class. This class has the same API as the ActionScript 3.0 version.

ArrayCollection

JavaScript proxy to the ActionScript ArrayCollection class. This class has the same API as the ActionScript 3.0 version.

Sort

JavaScript proxy to the ActionScript mx.collections.Sort class. This class has the same API as the ActionScript 3.0 version.

SortField

JavaScript proxy to the ActionScript mx.collections.SortField class. This class has the same API as the ActionScript 3.0 version.

Producer

JavaScript proxy to the ActionScript mx.messaging.Producer class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
function libraryReady()
{
    producer = new Producer();
    producer.setDestination("dashboard_chat");
}

function sendChat(user, msg, color)
{
    var message = new AsyncMessage();
    var body = new Object();
    body.userId = user;
    body.msg = msg;
    body.color = color;
    message.setBody(body);
    producer.send(message);
}
...
</script>

Consumer

JavaScript proxy to the ActionScript mx.messaging.Consumer class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
function libraryReady()
{
    consumer = new Consumer();
    consumer.setDestination("dashboard_chat");
    consumer.addEventListener("message", messageHandler);
    consumer.subscribe();
}

function messageHandler(event)
{
    body = event.getMessage().getBody();
    alert(body.userId + ":" + body.msg);
}
...
</script>

AsyncMessage

Description

JavaScript proxy to the ActionScript mx.messaging.AsyncMessage class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
function libraryReady()
{
    producer = new Producer();
    producer.setDestination("dashboard_chat");
}

function sendChat(user, msg, color)
{
    var message = new AsyncMessage();
    var body = new Object();
    body.userId = user;
    body.msg = msg;
    body.color = color;
    message.setBody(body);
    producer.send(message);
}
...
</script>

ChannelSet

JavaScript proxy to the ActionScript mx.messaging.ChannelSet class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
    function libraryReady()
    {
         alert("Library Ready");

        var cs = new ChannelSet();
        cs.addChannel(new AMFChannel("my-polling-amf",
            "http://servername:8100/app/messagebroker/amfpolling"));

        p = new Producer();
        p.setDestination("MyJMSTopic");
        p.setChannelSet(cs);

        c = new Consumer();
        c.setDestination("MyJMSTopic");
        c.addEventListener("message", messageHandler);
        c.setChannelSet(cs);
        c.subscribe();
    }
...
</script>

AMFChannel

JavaScript proxy to the ActionScript mx.messaging.channels.AMFChannel class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
    function libraryReady()
    {
         alert("Library Ready");

        var cs = new ChannelSet();
        cs.addChannel(new AMFChannel("my-polling-amf",
            "http://servername:8100/app/messagebroker/amfpolling"));

        p = new Producer();
        p.setDestination("MyJMSTopic");
        p.setChannelSet(cs);

        c = new Consumer();
        c.setDestination("MyJMSTopic");
        c.addEventListener("message", messageHandler);
        c.setChannelSet(cs);
        c.subscribe();
    }
...
</script>

HTTPChannel

JavaScript proxy to the ActionScript mx.messaging.channels.HTTPChannel class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
    function libraryReady()
    {
         alert("Library Ready");

        var cs = new ChannelSet();
        cs.addChannel(new HTTPChannel("my-http",
            "http://servername:8100/app/messagebroker/http"));

        p = new Producer();
        p.setDestination("MyJMSTopic");
        p.setChannelSet(cs);

        c = new Consumer();
        c.setDestination("MyJMSTopic");
        c.addEventListener("message", messageHandler);
        c.setChannelSet(cs);
        c.subscribe();
    }
...
</script>

SecureAMFChannel

JavaScript proxy to the ActionScript mx.messaging.channels.SecureAMFChannel class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
    function libraryReady()
    {
         alert("Library Ready");

        var cs = new ChannelSet();
        cs.addChannel(new SecureAMFChannel("my-secure-amf",
            "https://servername:8100/app/messagebroker/secureamf"));

        p = new Producer();
        p.setDestination("MyJMSTopic");
        p.setChannelSet(cs);

        c = new Consumer();
        c.setDestination("MyJMSTopic");
        c.addEventListener("message", messageHandler);
        c.setChannelSet(cs);
        c.subscribe();
    }
...
</script>

SecureHTTPChannel

JavaScript proxy to the ActionScript mx.messaging.channels.SecureHTTPChannel class. This class has the same API as the ActionScript 3.0 version.

Example

...
<script>
    function libraryReady()
    {
         alert("Library Ready");

        var cs = new ChannelSet();
        cs.addChannel(new SecureHTTPChannel("my-secure-http",
            "https://servername:8100/app/messagebroker/securehttp"));
        cs.addChannel(new AMFChannel("my-polling-amf",
            "/app/messagebroker/amfpolling"));

        p = new Producer();
        p.setDestination("MyJMSTopic");
        p.setChannelSet(cs);

        c = new Consumer();
        c.setDestination("MyJMSTopic");
        c.addEventListener("message", messageHandler);
        c.setChannelSet(cs);
        c.subscribe();
    }
...
</script>

FDMSLib JavaScript

The bridge provides a gateway between the JavaScript virtual machine and the ActionScript virtual machine for making calls to objects hosted by Flash Player. This bridge is designed specifically to handle various aspects of asynchronous calls that the Messaging APIs require.

Example

/**
 *Once the FDMSBridge SWF file is loaded, this method is called.
*/
function initialize_FDMSBridge(typeData)
{
    for (var i=0; i<typeData.length; i++)
    FDMSBridge.addTypeInfo(typeData[i]);

    // setup ArrayCollection etc.
    ArrayCollection.prototype = 
        FDMSBridge.getTypeFromName("mx.collections::ArrayCollection");
    ...
    // now callback the page specific code indicating that initialization is
        complete
    FDMSBridge.initialized();
}


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/blazeds/1/blazeds_devguide/ajaxds_4.html