easyXDM v1.8.0 relased

A lot has been going on with easyXDM over the past week, and I am proud to finally be able to release a version where all transport types, even the ones for IE6, deliver the same set of features.

From now on all the transports (and all the relying classes) supports

  • Reliability, ‘guaranteed’ delivery of messages
    The new ReliableBehavior adds this to the HashTransport
  • Sender-verification,  verifying that the message originates from the original sender. This removes the risk of malicious sites spoofing the sender
    This is added to the HashTransport and NameTransport by the VerifyBehavior
  • Queueing, you can now send multiple messages in the same js thread
    This is added to the HashTransport and NameTransport by the QueueBehavior

Behaviors

So what are these behaviors mentioned? Well, a behavior modifies the way a transport works, and it works by sending all events and messages through a pipeline of behaviors, where each one can let it pass, inspect it, modify it, block it etc. Each behavior is automatically chained with the others so that they form a stack, where in principal, each layer talks to the corresponding layer on the other end.

One example of this in action is the fragmentation. When the QueueBehavior receives an outgoing message that is larger than the max fragment size, then instead of queueing only one message, it will queue each fragment with a fragment identifier. The QueueBehaviors dispatcher will then send each message as fast as it can (it gets a callback from the next Behavior in he line when the message is delivered).

On the other end multiple ingoing messages will received at the QueueBehavior, but the message won’t be passed on until all fragments has arrived.

Using behaviors instead of applying the functionality directly to the classes adds a lot to the table

  • Re-usability, the same behavior can be applied to all transports that accepts these.
  • Separation, each new feature is contained in a separate class, and since the pipeline is layered, you can safely introduce e.g sender-verification without risking breaking the code that handles the sending/receiving.
  • Structure, the code is a lot easier to read and understand, and adding new behaviors is a breeze.

This is a sample from the HashTransport and shows how behaviors are applied internally

easyXDM.applyBehaviors(this, [
    new easyXDM.transport.behaviors.ReliableBehavior({
        timeout: ((useResize ? 50 : pollInterval * 1.5) + (usePolling ? pollInterval * 1.5 : 50))
    }),
    new easyXDM.transport.behaviors.QueueBehavior({
        maxLength: 4000 - _remoteUrl.length
    }),
    new easyXDM.transport.behaviors.VerifyBehavior({
        initiate: isHost
    })
]);

In the future these will be overridable, and you will be able to inject your own if you want to.

Conclusion

If you haven’t already, go download the newest version and enjoy the new features!

5 thoughts on “easyXDM v1.8.0 relased

  1. When NameTransport sending message, the ‘Secret’ will write into name.html’s window.name which is readable by all script (in the same origin). I can listen to the name.html’s onload event and catch the ‘Secret’.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>