HTML and CSS Reference
In-Depth Information
console.log("subscribed to " + src);
var onerror = function(error) {
var buttonClicked = function(btn) {
client.send(dest, null,;
hasUserPicked = true;
console.log("message sent: " +;
// Setting the background color of the button
// representing the user's choice to orange.
// Disabling all the buttons (to prevent changing the vote).
$("#" +"background-color", "orange");
$("#rockBtn").attr("disabled", "disabled");
$("#paperBtn").attr("disabled", "disabled");
$("#scissorsBtn").attr("disabled", "disabled");
// Checking if the other user has moved yet. If so,
// we display the buttons that were drawn beforehand
// (see onconnect)
if (hasOpponentPicked) {
$("#opponentsButtons").css("visibility", "visible");
client.disconnect(function() {
onerror = function() {};
} else {
$("#instructions").html("<p>Waiting for opponent...</p>");
To run the app, ensure ActiveMQ is WebSocket-enabled (as shown in Listing 5-4),
run ActiveMQ, and then open index.html in your WebSocket-enabled browser.
Monitoring Apache ActiveMQ
ActiveMQ provides a simple monitoring interface that gives you insight into what's happening
under the covers. To access the management interface, click the Manage ActiveMQ broker
link on the ActiveMQ Welcome page, or navigate to . After
running the Rock Paper Scissors demo once, you will have two queues, one for each player.
In our example, the opponents are Peter and Vanessa, and the queues are named after them.
As Figure 5-13 shows, each queue has one consumer (the opponent player), and we sent one
message to each queue (message enqueued). Both of these messages were dequeued soon
thereafter (message dequeued).
Search WWH ::

Custom Search