NAME
Stardust - the simplest COMET server I could imagine
SYNOPSIS
Installing Stardust:
$ sudo cpan Stardust
Running the COMET server on port 5555:
$ stardust.pl --port=5555 --base=/comet
Making pages subscribe to channel 'foo':
<script>
var uniqueId = Math.random().toString();
$.ev.loop('/comet/channel/foo/'+uniqueId, {
"*": function(ev) {
}
});
</script>
Posting JSON messages to channel 'foo':
curl -d 'm={ "type": "TestMessage", "data": [3, 2, 1] }' \
http://localhost:5555/comet/channel/foo
DESCRIPTION
Stardust is a simple COMET server that can be integrated alongside existing web applications.
CONCEPTS
Message
Messages are just abritrary JSON objects.
Channel
Channels are where messages travel trough.
API
Communication with the Stardust COMET server uses JSON over HTTP. The following URLs represent your API.
GET /
This is just a little informational JSON-encoded data that tells you what version of the Stardust server you're using.
GET /channel
This returns a list of all the channel names currently in use as a JSON-encoded array of strings.
GET /channel/([\w+]+)
This returns info about the specified channels as a JSON-encoded array of objects.
POST /channel/([\w+]+)
This allows one to send a message to the specified channels.
Parameters:
- m
-
an JSON-encoded object. This parameter may be repeated if you want to send more than one message per POST request.
GET /channel/([\w+]+)/stream/([.\d]+)
Long poll on this URL to receive a stream of messages as they become available. They will come back to you as a JSON-encoded array of objects.
CONFIGURATION
nginx static + stardust
upstream stardust_com_et {
server 127.0.0.1:5742;
}
server {
listen 80;
server_name stardust.com.et;
location / {
root /www/stardust.com.et;
index index.html index.htm;
}
location /comet {
proxy_pass http://stardust_com_et;
}
}
nginx fastcgi + stardust
TODO
nginx reverse proxy + stardust
TODO
apache2 static + stardust
<VirtualHost *:80>
ServerName stardust.com.et
DocumentRoot /www/stardust.com.et
CustomLog logs/stardust.com.et-access_log combined
ErrorLog logs/stardust.com.et-error_log
<Directory "/www/stardust.com.et">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ProxyRequests Off
ProxyPass /comet http://127.0.0.1:5742/comet
ProxyPassReverse /comet http://127.0.0.1:5742/comet
</VirtualHost>
apache2 fastcgi + stardust
TODO
apache2 reverse proxy + stardust
TODO
SEE ALSO
AUTHOR
John BEPPU <beppu@cpan.org>
SPECIAL THANKS
Thanks to Marc Lehmann for his work on AnyEvent and Coro.
Thanks to Brock Wilcox and Scott Walters for their work on Continuity.
COPYRIGHT
Copyright (c) 2009 John BEPPU <beppu@cpan.org>.
The "MIT" License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.