A Websocket/HTTP message bus.
Open WebSocket connections to any path to create a bus, messages sent to it will be relayed to all other WebSocket connections that were made to the same bus.
An HTTP GET request on any path will retrieve the last message sent to that bus.
An HTTP POST request on any path will push it's request body to the bus and it's subscribers.
Currently the build is left to rebar so you'll have to have that installed.
rebar get-deps
rebar compile
Starting Push Me Pull You is simple. If you want to start it run ./start.sh
, you can work out the rest of the controls for yourself. To paraphrase a certain infullable computer.
var ws = new WebSocket( "ws://localhost:8000/foo" );
ws.onopen = function() {
console.log( "Connected" );
};
ws.onclose = function() {
console.log( "Closed" );
};
ws.onmessage = function( msg ) {
msg = JSON.parse( msg.data );
console.log( msg );
};
ws.send( JSON.stringify( { hello: "world" } ) );
The last message sent to a bus can be retrieved by performing a GET request to it's URL.
curl http://localhost:8000/foo
You can a message to a bus over HTTP simply by POSTing it straight to the bus URL.
curl --data "{\"hello\":\"world\"}" http://localhost:8000/foo
There are two "methods" as such on every bus, subscribe
and unsubscribe
.
token
Any string that you want. It's just to differenciate subscribers. You'll need it to unsubscribe later.url
The URL that you want to have the messages POSTed to.curl --data "token=mytoken&url=http://localhost/" http://localhost:8000/foo.subscribe
curl --data "token=mytoken&url=http://localhost/" http://localhost:8000/foo.unsubscribe
See COPYING.