An open API service indexing awesome lists of open source software.

https://github.com/progrium/cometcatchr

An opinionated Comet client in Flash for Javascript
https://github.com/progrium/cometcatchr

Last synced: 10 months ago
JSON representation

An opinionated Comet client in Flash for Javascript

Awesome Lists containing this project

README

          

CometCatchr
===========

An opinionated Comet stream client in Flash to be used by Javascript.

You embed CometCatchr and specify a URL and a Javascript callback. It connects
to the URL and listens for JSON data (expecting Transfer-Type: chunked). When
it receives JSON, it parses it and passes it to you via your callback.

Using CometCatchr, you don't need to use complicated JS libraries and hacks
for cross-browser, cross-domain Comet support. It also doesn't rely on long-
polling. It always uses a persistent socket connection.

Using CometCatcher
==================

Just embed it as you would any Flash, passing it these parameters:

* url - Required. A URL to connect to.
* callback - Required. A Javascript function to pass JSON to.
* logger - Optional. A function to pass log/debug data to.
* retry - Optional. Number of retries to attempt. Default: 3
* policy - Optional. Explicit location of cross-domain policy file

Example using Firebug console for callback and logger:


This example ignores the common use of just to avoid redundancy.

Notes
=====

You need to host the SWF on the same domain as the HTML that embeds it. For
local debugging, you need to run on localhost, not file:/// or it doesn't
work. It uses a Flash socket, so providing cross-domain policy is up to you.

Also, the server response this expects pretty much matches Twitter's
stream API exactly. If they had a crossdomain.xml file or policy socket
server, you could just point CometCatcher right at one of their stream
endpoints, like: http://user:pass@stream.twitter.com/1/statuses/sample.json

Author
======

Jeff Lindsay

License
=======

MIT