aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/static/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/static/app.js')
-rw-r--r--src/main/resources/static/app.js60
1 files changed, 0 insertions, 60 deletions
diff --git a/src/main/resources/static/app.js b/src/main/resources/static/app.js
deleted file mode 100644
index 20fafd4..0000000
--- a/src/main/resources/static/app.js
+++ /dev/null
@@ -1,60 +0,0 @@
-const stompClient = new StompJs.Client({
- brokerURL: 'ws://localhost:8080/ws'
-});
-
-stompClient.onConnect = (frame) => {
- setConnected(true);
- console.log('Connected: ' + frame);
- stompClient.subscribe('/sub/chat', (greeting) => {
- showGreeting(JSON.parse(greeting.body).content);
- });
-};
-
-stompClient.onWebSocketError = (error) => {
- console.error('Error with websocket', error);
-};
-
-stompClient.onStompError = (frame) => {
- console.error('Broker reported error: ' + frame.headers['message']);
- console.error('Additional details: ' + frame.body);
-};
-
-function setConnected(connected) {
- $("#connect").prop("disabled", connected);
- $("#disconnect").prop("disabled", !connected);
- if (connected) {
- $("#conversation").show();
- }
- else {
- $("#conversation").hide();
- }
- $("#greetings").html("");
-}
-
-function connect() {
- stompClient.activate();
-}
-
-function disconnect() {
- stompClient.deactivate();
- setConnected(false);
- console.log("Disconnected");
-}
-
-function sendName() {
- stompClient.publish({
- destination: "/app/chat",
- body: JSON.stringify({'text': $("#name").val()})
- });
-}
-
-function showGreeting(message) {
- $("#greetings").append("<tr><td>" + message + "</td></tr>");
-}
-
-$(function () {
- $("form").on('submit', (e) => e.preventDefault());
- $( "#connect" ).click(() => connect());
- $( "#disconnect" ).click(() => disconnect());
- $( "#send" ).click(() => sendName());
-}); \ No newline at end of file