Permalink
Browse files

Merge branch 'master' of git@github.com:pgte/cyclops

  • Loading branch information...
2 parents 52cc812 + 5727f33 commit f2cb620f5062845103267af6207bbcf0f33f1249 @andregoncalves andregoncalves committed Dec 3, 2009
File renamed without changes.
View
@@ -0,0 +1,71 @@
+
+#user nobody;
+worker_processes 1;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ # '$status $body_bytes_sent "$http_referer" '
+ # '"$http_user_agent" "$http_x_forwarded_for"';
+
+ #access_log logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ #keepalive_timeout 65;
+
+ #gzip on;
+
+ # another virtual host using mix of IP-, name-, and port-based configuration
+ #
+
+ server {
+ listen 8000;
+
+ root /home/pgte/dev/cyclops;
+ # internal publish endpoint (keep it private / protected)
+
+ location /publish {
+ set $push_channel_id $arg_id; #/?id=239aff3 or somesuch
+ push_publisher;
+
+ push_store_messages on; # enable message queueing
+ push_message_timeout 2h; # expire buffered messages after 2 hours
+ push_max_message_buffer_length 10; # store 10 messages
+ push_min_message_recipients 1; # minimum recipients before purge
+ }
+
+ # public long-polling endpoint
+ location /activity {
+ push_subscriber;
+
+ # how multiple listener requests to the same channel id are handled
+ # - last: only the most recent listener request is kept, 409 for others.
+ # - first: only the oldest listener request is kept, 409 for others.
+ # - broadcast: any number of listener requests may be long-polling.
+ push_subscriber_concurrency broadcast;
+ set $push_channel_id $arg_id;
+ default_type text/plain;
+ }
+
+ }
+
+}
+
+
View
View
@@ -0,0 +1,45 @@
+<html>
+<head>
+ <script src="../../assets/javascripts/jquery-1.3.2.min.js" type="text/javascript" ></script>
+</head>
+<body>
+ <h1>Cyclops Publisher</h1>
+ <h2>Publish a message:</h2>
+ <form action="/publish?id=__ID__" method="POST">
+ <p>
+ <label for="id">Queue Id:</label><br />
+ <input type="test" name="id" id="id"/>
+ </p>
+ <p>
+ <label for="data">Data:</label><br />
+ <textarea name="data" id="data" /></textarea>
+ </p>
+ <p>
+ <input type="submit" name="post" id="post" />
+ </p>
+ </form>
+ <script type="text/javascript">
+ $(document).ready(function() {
+ $('form').submit(function() {
+ var action = this.action;
+ //console.info(action);
+ var id = $('#id').val();
+ //console.info(id);
+ action = action.replace(/__ID__/, id);
+ //console.info(action);
+ var data = $('#data').val();
+ console.info('data='+data);
+ console.info('posting...');
+ jQuery.post(action, data, function(data, textStatus) {
+ if(textStatus == 'success') {
+ alert('success. data='+data);
+ } else {
+ alert(textStatus);
+ }
+ });
+ return false;
+ });
+ });
+ </script>
+ </body>
+</html>
View
@@ -0,0 +1,57 @@
+<html>
+<head>
+ <script src="../../assets/javascripts/jquery-1.3.2.min.js" type="text/javascript" ></script>
+</head>
+<body>
+ <h1>Cyclops Subscriber</h1>
+ <h2>Subscribe to messages:</h2>
+ <form action="/activity?id=__ID__" method="POST">
+ <p>
+ <label for="id">Queue Id:</label><br />
+ <input type="test" name="id" id="id"/>
+ </p>
+ <p>
+ <input type="submit" name="post" id="post" value="Start Listening"/>
+ <input type="submit" name="stpo" id="stop" value="Stop Listening"/>
+ </p>
+ </form>
+ <h2>Events:</h2>
+ <div id="events"></div>
+ <script type="text/javascript">
+ keeplistening = true;
+ $(document).ready(function() {
+
+ $('#post').val('Listen').attr('disabled', false);
+
+ $('#stop').click(function() {
+ $('#post').val('Listen').attr('disabled', false);
+ keeplistening = false;
+ return false;
+ });
+
+ $('form').submit(function() {
+ keeplistening = true;
+ $('#post').val('listening...').attr('disabled', true);
+ var action = this.action;
+ //console.info(action);
+ var id = $('#id').val();
+ //console.info(id);
+ action = action.replace(/__ID__/, id);
+
+ var listen = function() {
+ $.get(action, {}, function(data) {
+ $("#events").append(data);
+ if(keeplistening)
+ listen(); // then launch again
+ });
+ };
+
+ listen();
+
+
+ return false;
+ });
+ });
+ </script>
+ </body>
+</html>

0 comments on commit f2cb620

Please sign in to comment.