More work on the WebSockets. Improved status and WS triggers. Better online/offline status.
This commit is contained in:
@@ -400,6 +400,9 @@ let events_session_data_struct: key_val = {
|
||||
trigger_reload__event_session_obj_li: null,
|
||||
trigger_reload__event_location_obj_id: null,
|
||||
trigger_reload__event_location_obj_li: null,
|
||||
|
||||
trigger__ws_connect: null,
|
||||
trigger__ws_disconnect: null,
|
||||
},
|
||||
|
||||
// Lead Retrievals (Exhibit)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
log_lvl?: number;
|
||||
ws_connect?: boolean;
|
||||
ws_connect?: boolean; // If true then we should be trying to connect to the WS server.
|
||||
ws_connect_status?: null|string;
|
||||
ws_server?: string;
|
||||
ws_retry_delay?: number;
|
||||
@@ -13,6 +13,8 @@ interface Props {
|
||||
msg?: null|string;
|
||||
type?: null|string; // msg, cmd, json, hello, bye
|
||||
trigger_send?: any;
|
||||
trigger_connect?: boolean;
|
||||
trigger_disconnect?: boolean;
|
||||
classes?: string;
|
||||
hide__ws_element?: boolean;
|
||||
hide__ws_form?: boolean;
|
||||
@@ -38,6 +40,8 @@ let {
|
||||
msg = $bindable(null),
|
||||
type = null,
|
||||
trigger_send = $bindable(null),
|
||||
trigger_connect = $bindable(false),
|
||||
trigger_disconnect = $bindable(false),
|
||||
classes = 'container p-1 bg-pink-100 text-xs mx-auto pb-16 mb-20 sm:mb-12 md:mb-8',
|
||||
hide__ws_element = $bindable(false),
|
||||
hide__ws_form = $bindable(true),
|
||||
@@ -294,9 +298,24 @@ function handle_send_ws_data() {
|
||||
|
||||
$effect(() => {
|
||||
if (ws_connect && group_id) {
|
||||
console.log('HERE!!!!!');
|
||||
ws_group = ws_connect_group_id({group_id: group_id, client_id: client_id});
|
||||
// } else if (!ws_connect) {
|
||||
// console.log('HERE!!!!!');
|
||||
// log_lvl = 1;
|
||||
// if (log_lvl) {
|
||||
// console.log(`WS: WS not set to connect. Need to close WS Group connection.`);
|
||||
// }
|
||||
// ws_group?.close();
|
||||
// ws_connect_status = 'disconnected';
|
||||
} else {
|
||||
console.log('HERE!!!!!');
|
||||
log_lvl = 1;
|
||||
if (log_lvl) {
|
||||
console.log(`WS: Not connecting. ws_connect=${ws_connect} group_id=${group_id}`);
|
||||
}
|
||||
ws_group?.close();
|
||||
ws_connect_status = 'disconnected';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -313,6 +332,31 @@ $effect(() => {
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (trigger_connect) {
|
||||
trigger_connect = false;
|
||||
if (!ws_connect) {
|
||||
ws_connect = true;
|
||||
}
|
||||
console.log('WS: Connect triggered!');
|
||||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (trigger_disconnect) {
|
||||
console.log('WS: Disconnect triggered!');
|
||||
trigger_disconnect = false;
|
||||
if (ws_connect) {
|
||||
ws_connect = false;
|
||||
}
|
||||
if (ws_group) {
|
||||
ws_group.close();
|
||||
ws_group = null;
|
||||
ws_connect_status = 'disconnected';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function preventDefault(fn) {
|
||||
return function (event) {
|
||||
|
||||
Reference in New Issue
Block a user