summaryrefslogtreecommitdiff
path: root/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/static/test-ws.js35
-rw-r--r--src/main/resources/static/test.html16
2 files changed, 26 insertions, 25 deletions
diff --git a/src/main/resources/static/test-ws.js b/src/main/resources/static/test-ws.js
index 48104537..662cf811 100644
--- a/src/main/resources/static/test-ws.js
+++ b/src/main/resources/static/test-ws.js
@@ -6,31 +6,17 @@ function connect() {
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
console.log('Connected: ' + frame);
-
- for (var i = 1; i < 10; i++) {
- subscribeTest(stompClient, '/test' + i);
- subscribeTest(stompClient, '/topic/test' + i);
- subscribeTest(stompClient, '/broadcast/test' + i);
- subscribeTest(stompClient, '/queue/test' + i);
- subscribeTest(stompClient, '/user/queue/test' + i);
- subscribeTest(stompClient, '/user/queue/topic/test' + i);
- subscribeTest(stompClient, '/user/queue/broadcast/test' + i);
- }
});
}
-function sendTest(indexes) {
- for (var i = 0; i < indexes.length; i++) {
- stompClient.send("/app/test" + indexes[i], {}, "test payload " + indexes[i]);
- }
+function send(endpoint, payload) {
+ stompClient.send(endpoint, {}, payload);
}
-function subscribeTest(stompClient, endpoint) {
- var id = endpoint.replace(new RegExp('/', 'g'), '') + '-data';
- $("#test-feeds").append('<tr><td>' + endpoint + '</td><td id="' + id + '">no data received yet</td></tr>');
+function subscribeTo(endpoint) {
+ $("#test-feeds").prepend('<tr><td>' + endpoint + '</td><td>Subscribed</td></tr>');
stompClient.subscribe(endpoint, function (data) {
- console.log("Received event on " + endpoint + ": data.body=" + data.body);
- $("#" + id).html('<strong>received "' + data.body + '"</strong>');
+ $("#test-feeds").prepend('<tr><td>' + endpoint + '</td><td>Received: <pre>' + data.body + '</pre></td></tr>');
});
}
@@ -38,9 +24,14 @@ $(function () {
$("form").on('submit', function (e) {
e.preventDefault();
});
- $("#send-test").click(function () {
- var indexesToSend = $("#test-index-field").val().split(',');
- sendTest(indexesToSend);
+ $("#send-btn").click(function () {
+ var endpoint = $("#path-field").val();
+ var payload = $("#payload-field").val();
+ send(endpoint, payload);
+ });
+ $("#subscribe-btn").click(function () {
+ var endpoint = $("#subscribe-path-field").val();
+ subscribeTo(endpoint);
});
});
diff --git a/src/main/resources/static/test.html b/src/main/resources/static/test.html
index 93c5d928..e19f9eb3 100644
--- a/src/main/resources/static/test.html
+++ b/src/main/resources/static/test.html
@@ -21,9 +21,19 @@
<form class="form-inline">
<div class="form-group">
- <label for="test-index-field">Send to /app/testX, with X in </label>
- <input id="test-index-field">
- <button id="send-test" class="btn btn-default" type="submit">Send</button>
+ <label for="subscribe-path-field">Path:</label>
+ <input id="subscribe-path-field" placeholder="path">
+ <button id="subscribe-btn" class="btn btn-default" type="submit">Subscribe</button>
+ </div>
+</form>
+
+<form class="form-inline">
+ <div class="form-group">
+ <label for="path-field">Path:</label>
+ <input id="path-field" placeholder="path">
+ <label for="payload-field">Payload:</label>
+ <input id="payload-field" placeholder="JSON payload">
+ <button id="send-btn" class="btn btn-default" type="submit">Send</button>
</div>
</form>
bgstack15