Permalink
Browse files

added some more value to the example and added documentation to README

  • Loading branch information...
1 parent 753e58b commit c69c839e270d1fa1f7f50c05d9d2893cbbe2f970 @Narigo Narigo committed Aug 11, 2012
@@ -255,6 +255,24 @@ To run it, open one or more browsers and point them to http://localhost:8080.
First connect, then try subscribing and sending messages and see how the separate browsers can interoperate on the event bus.
+## Eventbus Bridge Listener
+
+This example shows how the vert.x event bus listener can intercept messages from clients.
+
+To run the server:
+
+vertx run eventbusbridgelistener/bridge_server.js
+
+The example shows how the server can listen to events of client actions.
+
+You can always see that the server intercepts these messages by clicking "Refresh Log".
+
+To run it, open one or more browsers and point them to http://localhost:8080.
+
+First connect, then try sending/publishing messages or registering/unregistering handlers. You can see how the server intercepts these messages by refreshing the log. You are able to see with different browsers, that send will always do round robin. Publishing will be censored (never shown in the messages, only in the log).
+
+Registering a handler at "secret" will not be allowed, so you can see that even though the client can try to register a handler, it won't be able to see message sent to the address.
+
## Web application
This is a full end-end "real-time" web appplication which has a modern JavaScript client side MVVM application that communicates via the event bus with a persistor.
@@ -12,6 +12,7 @@
width: 400px;
height: 300px;
overflow: scroll;
+ float: left;
}
body {
@@ -21,7 +22,7 @@
<body>
-<div id="sendbox" class="box">
+<div id="logbox" class="box">
<form onsubmit="return false;">
Address: <input type="text" id="address" value="someaddress"/><br />
@@ -34,18 +35,23 @@
<button id="connection">Connect</button>
<button id="refresh">Refresh log</button>
</form>
-
+<div>Log</div>
+<ul>
+</ul>
</div>
-<div id="logbox" class="box">
+<div id="messages" class="box">
+<div>Messages</div>
<ul>
</ul>
</div>
<script>
var eb = null;
- var dummyHandler = function() {};
+ var receiveHandler = function(data) {
+ $('#messages ul').append('<li>' + JSON.stringify(data) + '</li>');
+ };
function refreshLog() {
$.getJSON('/log.json', function(data) {
@@ -72,12 +78,12 @@
});
$('#register').click(function() {
if (eb) {
- eb.registerHandler($('#address').val(), dummyHandler);
+ eb.registerHandler($('#address').val(), receiveHandler);
}
});
$('#unregister').click(function() {
if (eb) {
- eb.unregisterHandler($('#address').val(), dummyHandler);
+ eb.unregisterHandler($('#address').val(), receiveHandler);
}
});
$('#connection').click(function() {
@@ -98,7 +104,6 @@
};
}
});
- $('#sendbox').show();
});
</script>

0 comments on commit c69c839

Please sign in to comment.