diff options
author | jbion <joffrey.bion@amadeus.com> | 2016-12-20 01:13:27 +0100 |
---|---|---|
committer | jbion <joffrey.bion@amadeus.com> | 2016-12-20 01:13:27 +0100 |
commit | 139cfb9ca348775d4eeed26dcc63f915c8dc42ee (patch) | |
tree | 3aa9c2f900fe8eb650cd0394bd098c8f0b747665 /src/main/resources/static | |
parent | Add conversion exception handling for bad input JSON format (diff) | |
download | seven-wonders-139cfb9ca348775d4eeed26dcc63f915c8dc42ee.tar.gz seven-wonders-139cfb9ca348775d4eeed26dcc63f915c8dc42ee.tar.bz2 seven-wonders-139cfb9ca348775d4eeed26dcc63f915c8dc42ee.zip |
Improve test page for custom subscriptions and msg testing
Diffstat (limited to 'src/main/resources/static')
-rw-r--r-- | src/main/resources/static/test-ws.js | 35 | ||||
-rw-r--r-- | src/main/resources/static/test.html | 16 |
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> |