Skip to content

Commit 0df3a4b

Browse files
author
Karl Krukow
committed
license
1 parent c80ab02 commit 0df3a4b

File tree

3 files changed

+47
-10
lines changed

3 files changed

+47
-10
lines changed

README

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
LICENSE MIT:
2+
Copyright (c) 2011 [email protected]
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5+
6+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7+
8+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
10+
111
A robust full-featured Stomple client for JavaScript
212

313
Introduction in blog post:
@@ -7,14 +17,14 @@ http://blog.higher-order.net/2010/06/01/stomple-rc1-combining-websockets-and-rel
717
Note the word: scope is replaced by thisObj to avoid confusion
818

919
Quick Demo:
10-
1) Start hornetq
20+
1) Start hornetq
1121
krukow:~/Projects/private/stomple$ ./hornetq/bin/run.sh ./hornetq/examples/jms/stomp-websockets/server0
1222

1323
Open example in a browser that supports WebSockets (e.g., Chrome)
1424
2) open example/transactional-chat.html
1525

1626
Running tests:
17-
1) Start hornetq
27+
1) Start hornetq
1828
krukow:~/Projects/private/stomple$ ./hornetq/bin/run.sh ./hornetq/examples/jms/stomp-websockets/server0
1929

20-
2) open test/all.html or which ever test you want to run...
30+
2) open test/all.html or which ever test you want to run...

example/transactional-chat.html

+23-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,27 @@
6969
url: "ws://localhost:61614/stomp",
7070
destination: "jms.topic.chat",
7171
login: "guest",
72-
passcode: "guest"
72+
passcode: "guest",
73+
socketOpen: function() {
74+
console.log("socket opened");
75+
},
76+
77+
socketMessage: function(msg) {
78+
console.log("socket msg");
79+
console.log(msg);
80+
},
81+
82+
socketClose: function(e) {
83+
console.log("socket close");
84+
console.log(e);
85+
},
86+
87+
socketError: function() {
88+
console.log("socket error");
89+
console.log(client.websocket);
90+
return false;
91+
}
92+
7393
});
7494
var msgHandler = {
7595
fn: function(msg) {
@@ -79,14 +99,14 @@
7999
};
80100
client.subscribe({
81101
handler: msgHandler.fn,
82-
scope: msgHandler,
102+
thisObj: msgHandler,
83103

84104
success: function() {//did subscription succeed?
85105
console.log("sub ok..");
86106
},
87107
failure: function(reason) {//did subscription fail?
88108
console.log(reason);
89-
}
109+
}
90110
});
91111
document.getElementById('inputText').focus();
92112

test/all.html

+11-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
<body class="yui3-skin-sam">
2929
<h1>Note: This requires a running Stomp server with destination jms.topic.chat (see README)</h1>
3030
<script type="text/javascript">
31-
31+
var resultsXML = {"result": "42"};
32+
3233
if (Stomple) {
3334
YUI({ logInclude: { TestRunner: true } }).use("test",'console', function(Y){
3435

@@ -40,15 +41,21 @@ <h1>Note: This requires a running Stomp server with destination jms.topic.chat (
4041
Y.Test.Runner.add(new Y.Test.Case(test_client_ack));
4142
Y.Test.Runner.add(new Y.Test.Case(test_disconnect));
4243

44+
var TestRunner = Y.Test.Runner;
45+
TestRunner.subscribe(TestRunner.COMPLETE_EVENT, function(){
46+
console.log("extract");
47+
var resultsObject = Y.Test.Runner.getResults();
48+
resultsXML = Y.Test.Runner.getResults(Y.Test.Format.XML);
49+
console.log(resultsXML);
50+
});
51+
4352
var yconsole = new Y.Console({
4453
newestOnTop: false
4554
});
4655
yconsole.render('#log');
4756

4857
//run the tests
49-
Y.Test.Runner.run();
50-
51-
58+
Y.Test.Runner.run();
5259

5360
});
5461
} else {

0 commit comments

Comments
 (0)