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