Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://jira.jboss.org/jira/browse/HORNETQ-279: Support Stomp over We…
…b Sockets * add stomp_ws protocol to support sending/receiving Stomp messages over HTML5 Web Sockets * add stomp-websockets example * documentation
- Loading branch information
Showing
26 changed files
with
1,151 additions
and
17 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
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
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
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,13 @@ | ||
@echo off | ||
|
||
set "OVERRIDE_ANT_HOME=..\..\..\tools\ant" | ||
|
||
if exist "..\..\..\src\bin\build.bat" ( | ||
rem running from TRUNK | ||
call ..\..\..\src\bin\build.bat %* | ||
) else ( | ||
rem running from the distro | ||
call ..\..\..\bin\build.bat %* | ||
) | ||
|
||
set "OVERRIDE_ANT_HOME=" |
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,15 @@ | ||
#!/bin/sh | ||
|
||
OVERRIDE_ANT_HOME=../../../tools/ant | ||
export OVERRIDE_ANT_HOME | ||
|
||
if [ -f "../../../src/bin/build.sh" ]; then | ||
# running from TRUNK | ||
../../../src/bin/build.sh "$@" | ||
else | ||
# running from the distro | ||
../../../bin/build.sh "$@" | ||
fi | ||
|
||
|
||
|
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,28 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE project [ | ||
<!ENTITY libraries SYSTEM "../../../thirdparty/libraries.ent"> | ||
]> | ||
<!-- | ||
~ Copyright 2009 Red Hat, Inc. | ||
~ Red Hat licenses this file to you under the Apache License, version | ||
~ 2.0 (the "License"); you may not use this file except in compliance | ||
~ with the License. You may obtain a copy of the License at | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
~ implied. See the License for the specific language governing | ||
~ permissions and limitations under the License. | ||
--> | ||
<project default="runRemote" name="HornetQ Stomp Over WebSockets Example"> | ||
|
||
<import file="../../common/build.xml"/> | ||
|
||
<target name="runRemote"> | ||
<antcall target="runExample"> | ||
<param name="example.classname" value="org.hornetq.jms.example.StompWebSocketExample"/> | ||
<param name="hornetq.example.runServer" value="false"/> | ||
</antcall> | ||
</target> | ||
|
||
</project> |
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,99 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
body { | ||
font-family: 'Helvetica Neue', Helvetica, Verdana, Arial, sans-serif; | ||
padding: 10px; | ||
} | ||
|
||
#disconnect { | ||
display: none; | ||
} | ||
#subscribe { | ||
display: none; | ||
} | ||
|
||
#debug { | ||
background-color: #F0F0F0; | ||
font-size: 12px; | ||
height: 75%; | ||
overflow: auto; | ||
padding: 10px; | ||
position: absolute; | ||
right: 10px; | ||
top: 10px; | ||
width: 250px; | ||
z-index: 100; | ||
} | ||
|
||
#send_form { | ||
bottom: 5px; | ||
position: absolute; | ||
width: 99%; | ||
} | ||
|
||
#send_form #send_form_input { | ||
border: 1px solid #CCC; | ||
font-size: 16px; | ||
height: 20px; | ||
padding: 5px; | ||
width: 98%; | ||
} | ||
|
||
#send_form input[disabled] { | ||
background-color: #EEE; | ||
} | ||
|
||
#messages { | ||
bottom: 25px; | ||
left: 0; | ||
overflow: auto; | ||
padding: 5px; | ||
right: 0; | ||
top: 2em; | ||
z-index: -1; | ||
} | ||
|
||
.message { | ||
width: 95%; | ||
} | ||
|
||
.timestamp { | ||
font-size: 12px; | ||
} | ||
|
||
.me, .nick { | ||
float: left; | ||
width: 100px; | ||
} | ||
|
||
.me { | ||
color: #F99; | ||
} | ||
|
||
.nick { | ||
color: #99F; | ||
} | ||
|
||
.status { | ||
background-color: #DDD; | ||
} | ||
|
||
form dt { | ||
clear:both; | ||
width:19%; | ||
float:left; | ||
text-align:right; | ||
} | ||
|
||
form dd { | ||
float:left; | ||
width:80%; | ||
margin:0 0 0.5em 0.25em; | ||
} | ||
|
||
input { | ||
width: 320px; | ||
} |
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,51 @@ | ||
$(document).ready(function(){ | ||
|
||
var client, destination; | ||
|
||
$('#connect_form').submit(function() { | ||
var url = $("#connect_url").val(); | ||
var login = $("#connect_login").val(); | ||
var passcode = $("#connect_passcode").val(); | ||
destination = $("#destination").val(); | ||
|
||
client = Stomp.client(url); | ||
|
||
// this allows to display debug logs directly on the web page | ||
client.debug = function(str) { | ||
$("#debug").append(str + "\n"); | ||
}; | ||
// the client is notified when it is connected to the server. | ||
var onconnect = function(frame) { | ||
debug("connected to Stomp"); | ||
$('#connect').fadeOut({ duration: 'fast' }); | ||
$('#disconnect').fadeIn(); | ||
$('#send_form_input').removeAttr('disabled'); | ||
|
||
client.subscribe(destination, function(message) { | ||
$("#messages").append("<p>" + message.body + "</p>\n"); | ||
}); | ||
}; | ||
client.connect(login, passcode, onconnect); | ||
|
||
return false; | ||
}); | ||
|
||
$('#disconnect_form').submit(function() { | ||
client.disconnect(function() { | ||
$('#disconnect').fadeOut({ duration: 'fast' }); | ||
$('#connect').fadeIn(); | ||
$('#send_form_input').addAttr('disabled'); | ||
}); | ||
return false; | ||
}); | ||
|
||
$('#send_form').submit(function() { | ||
var text = $('#send_form_input').val(); | ||
if (text) { | ||
client.send(destination, {foo: 1}, text); | ||
$('#send_form_input').val(""); | ||
} | ||
return false; | ||
}); | ||
|
||
}); |
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,54 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Chat Example Using Stomp Over Web Sockets</title> | ||
<link rel="stylesheet" href="chat.css" /> | ||
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script> | ||
<script src='stomp.js'></script> | ||
<script src='chat.js'></script> | ||
<script> | ||
$(document).ready(function() { | ||
var supported = ("WebSocket" in window); | ||
if(!supported) { | ||
var msg = "Your browser does not support Web Sockets. This example will not work properly.<br>"; | ||
msg += "Please use a Web Browser with Web Sockets support (WebKit or Google Chrome)."; | ||
$("#connect").html(msg); | ||
} | ||
}); | ||
</script> | ||
</head> | ||
<body> | ||
|
||
<div id='connect'> | ||
<form id='connect_form'> | ||
<dl> | ||
<dt><label for=connect_url>Server URL</label></dt> | ||
<dd><input name=url id='connect_url' value='ws://localhost:61614/stomp'></dd> | ||
<dt><label for=connect_login>Login</label></dt> | ||
<dd><input id='connect_login' placeholder="User Login" value="guest"></dd> | ||
<dt><label for=connect_passcode>Password</label></dt> | ||
<dd><input id='connect_passcode' type=password placeholder="User Password" value="guest"></dd> | ||
<dt><label for=destination>Destination</label></dt> | ||
<dd><input id='destination' placeholder="Destination" value="jms.topic.chat"></dd> | ||
<dt> </dt> | ||
<dd><input type=submit id='connect_submit' value="Connect"></dd> | ||
</dl> | ||
</form> | ||
|
||
<p>Use the form above to connect to the Stomp server and subscribe to the destination.</p> | ||
<p>Once connected, you can send messages to the destination with the text field at the bottom of this page</p> | ||
</div> | ||
<div id="disconnect"> | ||
<form id='disconnect_form'> | ||
<input type=submit id='disconnect_submit' value="Disconnect"> | ||
</form> | ||
</div> | ||
<pre id="debug"></pre> | ||
<div id="messages"> | ||
</div> | ||
<form id='send_form'> | ||
<input id='send_form_input' placeholder="Type your message here" disabled /> | ||
</form> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.