Cross Frame Communication: Another Comet Application

by Kris ZypFebruary 29th, 2008

Native cross frame communication capabilities are coming, but in the meantime we struggle with various hacks to facilitate communication between pages from different sources. The most commonly used approach is fragment identifier messaging (FIM) with various flavors that relies on setting the fragment identifier in the URL of a frame to expose messages, and having recipients poll for URL changes to receive messages. This approach will be used by the OpenAjax hub 1.1 to facilitate pub/sub messaging across frames. Another library was just released that uses an approach which involves loading a page from a target domain with a query containing a message to be stored in a cookie for retrieval from the target page. Unfortunately both of these approaches rely on polling, which is slow, and each poll has a small limit on data size due to URL size limits and cookie size limits. Polling with these small packets is very slow for large amounts of data. Also, FIM causes URL changes which often triggers a click in IE, and can result in machine-gun sound effects during messaging.

Interestingly, Comet could also be used for cross frame communication. If a page from foo.com wants to communicate with a page from bar.com, bar.com could setup a pub/sub Comet channel specific to the loaded instance of the page, and foo.com could subscribe to it using remote callback scripts. With this setup, bar.com could publish a message to its server, and foo.com would immediately receive a message (through a loaded callback script) from bar.com. Since the message is sent in a script, there is no data packet limit, and no polling required during message transmission.

This would certainly be a rather involved approach and would probably not be optimal in most situations, but in limited cases where large messages need to be transferred from one frame to another, and both frames have high-bandwidth access to the same server, this could be a faster messaging approach. Comet has numerous applications and it is interesting to note that one of them may actually be providing a solution for a certain class of cross frame messaging needs.

Comments are closed.


Copyright 2015 Comet Daily, LLC. All Rights Reserved