Skip to content

Commit

Permalink
sonar fix, formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
gtiwari333 authored Oct 9, 2023
1 parent 60f8b4d commit 76c9a42
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
39 changes: 13 additions & 26 deletions main-app/main-webapp/src/main/resources/static/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

}

//common behaviour
jQuery(document).ready(function () {
//init username-link

Expand All @@ -32,29 +31,21 @@


function initStompJs() {

//TODO: implement auto reconnect on disconnect


stompClient = new StompJs.Client({
brokerURL: 'ws://localhost:8081/app-websockets-main-endpoint',
connectHeaders: {
login: 'user',
passcode: 'password',
},
debug: function (str) {
console.log(str);
},
reconnectDelay: 5000,
heartbeatIncoming: 4000,
heartbeatOutgoing: 4000,
brokerURL: 'ws://localhost:8081/app-websockets-main-endpoint',
debug: function (str) {
console.log(str);
},
reconnectDelay: 5000,
heartbeatIncoming: 4000,
heartbeatOutgoing: 4000,
});

stompClient.onConnect = function(frame){
stompClient.onConnect = function (frame) {

console.log('Connected: ' + frame);
stompClient.subscribe('/topic/global-messages', function (msg) {
console.log(msg);
console.log("Global message" + msg);
$.toast({
text: msg.body,
icon: 'info',
Expand All @@ -64,9 +55,9 @@
});
});

//this is used to send receive messages meant for specific user
//this (/user/* path) is used to send/receive messages meant for specific user
stompClient.subscribe('/user/topic/review-results', function (msg) {
console.log("User messages" + msg);
console.log("User message" + msg);
$.toast({
text: msg.body,
icon: 'info',
Expand All @@ -78,12 +69,8 @@
}

stompClient.onStompError = function (frame) {
// Will be invoked in case of error encountered at Broker
// Bad login/passcode typically will cause an error
// Complaint brokers will set `message` header with a brief message. Body may contain details.
// Compliant brokers will terminate the connection after any error
console.log('Broker reported error: ' + frame.headers['message']);
console.log('Additional details: ' + frame.body);
console.log('Broker reported error: ' + frame.headers['message']);
console.log('Additional details: ' + frame.body);
};

stompClient.activate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<script src="/webjars/jquery/3.6.1/jquery.min.js"></script>
<script src="/webjars/bootstrap/5.0.1/js/bootstrap.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@stomp/[email protected]/bundles/stomp.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@stomp/[email protected]/bundles/stomp.umd.min.js" integrity="sha512-vVSeibxEBKAfSkPFQ6vluowRjL1BsFLHz0yYyIq60UGN/aOtm4n5u5jHHaLtvc8pgkNAYsRkwvpkgEcBcefaPQ==" crossorigin="anonymous"></script>
<script src="/webjars/jquery-toast-plugin/1.3.2/dist/jquery.toast.min.js"></script>
<script th:src="@{/static/js/wro-commons.js}"></script>
<!-- we can pass in additional script if needed -->
Expand Down

0 comments on commit 76c9a42

Please sign in to comment.