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
- Host: GitHub
- URL: https://github.com/progrium/cometcatchr
- Owner: progrium
- License: mit
- Created: 2009-11-30T05:48:53.000Z (over 16 years ago)
- Default Branch: master
- Last Pushed: 2010-04-15T01:07:56.000Z (about 16 years ago)
- Last Synced: 2025-08-24T01:59:19.817Z (11 months ago)
- Language: JavaScript
- Homepage:
- Size: 1.44 MB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- License: LICENSE
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