@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.
@@ -2630,10 +2630,16 @@ var __log_callback__ = null;
2630
2630
  function set_log_callback(fn) {
2631
2631
  __log_callback__ = typeof fn === "function" ? fn : null;
2632
2632
  }
2633
+ var __in_log_callback__ = false;
2633
2634
  function emit_log_callback(level, msg, hora) {
2634
- if (__log_callback__) try {
2635
- __log_callback__(level, msg, hora);
2636
- } catch (e) {}
2635
+ if (__log_callback__ && !__in_log_callback__) {
2636
+ __in_log_callback__ = true;
2637
+ try {
2638
+ __log_callback__(level, msg, hora);
2639
+ } catch (e) {} finally {
2640
+ __in_log_callback__ = false;
2641
+ }
2642
+ }
2637
2643
  }
2638
2644
  function set_remote_log_functions(remote_log_fn) {
2639
2645
  if (remote_log_fn) {
@@ -5583,7 +5589,7 @@ function mt_inject_event(gobj, event, kw, src) {
5583
5589
  ***************************************************************/
5584
5590
  function mt_subscription_added(gobj, subs) {
5585
5591
  let priv = gobj.priv;
5586
- if (gobj_current_state(gobj) !== "ST_SESSION") return 0;
5592
+ if (gobj_current_state(gobj) !== "ST_SESSION" || !priv.websocket) return 0;
5587
5593
  if (priv.inside_on_open) return 0;
5588
5594
  return send_remote_subscription(gobj, subs);
5589
5595
  }
@@ -5592,7 +5598,7 @@ function mt_subscription_added(gobj, subs) {
5592
5598
  ***************************************************************/
5593
5599
  function mt_subscription_deleted(gobj, subs) {
5594
5600
  let priv = gobj.priv;
5595
- if (gobj_current_state(gobj) !== "ST_SESSION") return 0;
5601
+ if (gobj_current_state(gobj) !== "ST_SESSION" || !priv.websocket) return 0;
5596
5602
  if (priv.inside_on_open) return 0;
5597
5603
  if (empty_string(subs.event)) return 0;
5598
5604
  let kw = {};
@@ -5713,6 +5719,10 @@ function send_iev(gobj, iev) {
5713
5719
  trace_ievent_callback(prefix, iev, 1, size);
5714
5720
  } else trace_inter_event(gobj, prefix, iev);
5715
5721
  }
5722
+ if (!priv.websocket || priv.websocket.readyState !== WebSocket.OPEN) {
5723
+ log_warning(`${gobj_short_name(gobj)}: send_iev(): websocket not open, message lost`);
5724
+ return -1;
5725
+ }
5716
5726
  try {
5717
5727
  priv.websocket.send(msg);
5718
5728
  } catch (e) {