-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gleicon Moraes
committed
Mar 9, 2010
1 parent
546f0d7
commit 286d81d
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Now that cyclone has websockets support, there is a read-only websocket interface for RestMQ. | ||
Initially it will echoes back any message send to it, and will provide the latest messages to it too. | ||
|
||
The url format is http://restmqserver:port/ws/<queuename> | ||
|
||
Example: http://localhost:8888/ws/test | ||
|
||
To test it, copy contrib/interact.html to your webserver, configure it if necessary (just change websocket url or queue name if you need). | ||
Open it in your browser and execute in console: | ||
|
||
python restmq_engine.py -p oi | ||
|
||
or | ||
|
||
curl -X POST -d "queue=test&value=foobar" http://localhost:8888/q/test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<html> | ||
<head> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
<script> | ||
$(document).ready(function(){ | ||
// from joe amstrong's websocket example | ||
// http://armstrongonsoftware.blogspot.com/ | ||
// his ! syntax idea should be the standard for reaching tag content | ||
var ws; | ||
|
||
if ("WebSocket" in window) { | ||
debug("Horray you have web sockets Trying to connect..."); | ||
ws = new WebSocket("ws://localhost:8888/ws/test"); | ||
|
||
ws.onopen = function() { | ||
// Web Socket is connected. You can send data by send() method. | ||
debug("connected..."); | ||
//ws.send("hello from the browser"); | ||
//ws.send("more from browser"); | ||
}; | ||
|
||
run = function() { | ||
var val=$("#i1").val(); // read the entry | ||
$("#i1").val(""); // and clear it | ||
ws.send(val); // tell erlang | ||
return true; // must do this | ||
}; | ||
|
||
ws.onmessage = function (evt) { | ||
var data = evt.data; | ||
$("#out").html(data); | ||
}; | ||
|
||
ws.onclose = function() { | ||
debug(" socket closed"); | ||
}; | ||
} else { | ||
alert("You have no web sockets"); | ||
}; | ||
|
||
function debug(str){ | ||
$("#debug").append("<p>" + str); | ||
}; | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
|
||
<h1>Interaction experiment</h1> | ||
|
||
<h2>Debug</h2> | ||
<div id="debug"></div> | ||
|
||
<fieldset> | ||
<legend>Last message time: </legend> | ||
<div id="clock"></div> | ||
</fieldset> | ||
|
||
<fieldset> | ||
<legend>queue: test - last element</legend> | ||
<div id="out">Output should appear here</div> | ||
</fieldset> | ||
|
||
<p>Enter something in the entry below, | ||
the server will send it back to the out region above | ||
</p> | ||
|
||
<fieldset> | ||
<legend>entry</legend><!-- 42 --> | ||
<P>Enter: <input id="i1" onchange="run()" size ="42"></p> | ||
</fieldset> | ||
|
||
</body> | ||
</html> | ||
|