@yuneta/gobj-js 7.7.0 → 7.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2633,10 +2633,16 @@
2633
2633
  function set_log_callback(fn) {
2634
2634
  __log_callback__ = typeof fn === "function" ? fn : null;
2635
2635
  }
2636
+ var __in_log_callback__ = false;
2636
2637
  function emit_log_callback(level, msg, hora) {
2637
- if (__log_callback__) try {
2638
- __log_callback__(level, msg, hora);
2639
- } catch (e) {}
2638
+ if (__log_callback__ && !__in_log_callback__) {
2639
+ __in_log_callback__ = true;
2640
+ try {
2641
+ __log_callback__(level, msg, hora);
2642
+ } catch (e) {} finally {
2643
+ __in_log_callback__ = false;
2644
+ }
2645
+ }
2640
2646
  }
2641
2647
  function set_remote_log_functions(remote_log_fn) {
2642
2648
  if (remote_log_fn) {
@@ -5586,7 +5592,7 @@
5586
5592
  ***************************************************************/
5587
5593
  function mt_subscription_added(gobj, subs) {
5588
5594
  let priv = gobj.priv;
5589
- if (gobj_current_state(gobj) !== "ST_SESSION") return 0;
5595
+ if (gobj_current_state(gobj) !== "ST_SESSION" || !priv.websocket) return 0;
5590
5596
  if (priv.inside_on_open) return 0;
5591
5597
  return send_remote_subscription(gobj, subs);
5592
5598
  }
@@ -5595,7 +5601,7 @@
5595
5601
  ***************************************************************/
5596
5602
  function mt_subscription_deleted(gobj, subs) {
5597
5603
  let priv = gobj.priv;
5598
- if (gobj_current_state(gobj) !== "ST_SESSION") return 0;
5604
+ if (gobj_current_state(gobj) !== "ST_SESSION" || !priv.websocket) return 0;
5599
5605
  if (priv.inside_on_open) return 0;
5600
5606
  if (empty_string(subs.event)) return 0;
5601
5607
  let kw = {};
@@ -5716,6 +5722,10 @@
5716
5722
  trace_ievent_callback(prefix, iev, 1, size);
5717
5723
  } else trace_inter_event(gobj, prefix, iev);
5718
5724
  }
5725
+ if (!priv.websocket || priv.websocket.readyState !== WebSocket.OPEN) {
5726
+ log_warning(`${gobj_short_name(gobj)}: send_iev(): websocket not open, message lost`);
5727
+ return -1;
5728
+ }
5719
5729
  try {
5720
5730
  priv.websocket.send(msg);
5721
5731
  } catch (e) {