You\'re not logged it. Please
login ');
- }
- }
- // Put future Errorhandling here
- } else {
- if($('.radio_login_error').length != 0) {
- $(".radio_login_error" ).remove();
+ function initializeWebSocketConnection() {
+ try {
+ websocket = new WebSocket('ws://localhost:54322');
+ websocket.onopen = function(event) {
+ reconnectAttempts = 0;
+ websocketEnabled = true;
+ };
+ websocket.onmessage = function(event) {
+ try {
+ const data = JSON.parse(event.data);
+ handleWebSocketData(data);
+ } catch (error) {
}
- var band = frequencyToBand(data.frequency);
- CatCallbackURL=data.cat_url;
- if (band !== $("#band").val()) {
- $("#band").val(band);
- $("#band").trigger("change");
+ };
+ websocket.onerror = function(error) {
+ websocketEnabled=false;
+ };
+ websocket.onclose = function(event) {
+ websocketEnabled = false;
+
+ if (reconnectAttempts < 5) {
+ setTimeout(() => {
+ reconnectAttempts++;
+ initializeWebSocketConnection();
+ }, 2000 * reconnectAttempts);
+ } else {
+ $(".radio_cat_state" ).remove();
+ $('#radio_status').html('