@rootintf/protocol-2phw 1.2.4-api.1 → 2.0.3-api.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rootintf/protocol-2phw",
3
- "version": "1.2.4-api.1",
3
+ "version": "2.0.3-api.2",
4
4
  "description": "",
5
5
  "main": "dist/twoPhW.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,22 +28,22 @@
28
28
  "homepage": "https://gitlab.com/interface-x/npm-protocol-2PhW.git#readme",
29
29
  "dependencies": {
30
30
  "@knev/bitlogr": "^2.0.11",
31
- "@rootintf/json-msg": "^1.1.5",
32
- "ajv": "^8.17.1",
33
- "tslib": "^2.8.1"
31
+ "@rootintf/json-msg": "^2.0.6",
32
+ "ajv": "^8.17.1"
34
33
  },
35
34
  "devDependencies": {
36
- "@rollup/plugin-commonjs": "^28.0.3",
35
+ "@rollup/plugin-commonjs": "^29.0.0",
37
36
  "@rollup/plugin-json": "^6.1.0",
38
- "@rollup/plugin-node-resolve": "^16.0.1",
39
- "@rollup/plugin-typescript": "^12.1.2",
37
+ "@rollup/plugin-node-resolve": "^16.0.3",
38
+ "@rollup/plugin-typescript": "^12.3.0",
40
39
  "@types/ajv": "^0.0.5",
41
- "@types/node": "^22.15.23",
40
+ "@types/node": "^24.10.1",
42
41
  "ajv-cli": "^5.0.0",
43
- "del-cli": "^6.0.0",
44
- "jasmine": "^5.6.0",
45
- "rollup": "^4.39.0",
46
- "typescript": "^5.8.3",
47
- "uuid": "^11.1.0"
42
+ "del-cli": "^7.0.0",
43
+ "jasmine": "^5.13.0",
44
+ "rollup": "^4.53.3",
45
+ "tslib": "^2.8.1",
46
+ "typescript": "^5.9.3",
47
+ "uuid": "^13.0.0"
48
48
  }
49
49
  }
@@ -7,7 +7,7 @@
7
7
  "$schema" : "https://json-schema.org/draft/2019-09/schema",
8
8
  "definitions" : {
9
9
  "2PhW" : {
10
- "const": "1"
10
+ "const": "2"
11
11
  },
12
12
  "warp_id" : {
13
13
  "type" : "string"
package/src/twoPhW.ts CHANGED
@@ -9,7 +9,7 @@ import {
9
9
 
10
10
  // import { v4 as uuidv4 } from 'uuid'; // uuid is already a dep of JSON_Msg, so why not
11
11
  import { LOGR, l_array, l_concat, l_LL } from '@knev/bitlogr';
12
- import { JSON_Msg, JSON_Msg_msg, JSON_MsgAck_msg, l as l_json_msg_ } from '@rootintf/json-msg'
12
+ import { JSON_Msg, JSON_MsgEffect, JSON_MsgAck, l as l_json_msg_ } from '@rootintf/json-msg'
13
13
 
14
14
  import { EventLog, l as l_evtlog_ } from './EventLog-mem.mjs'
15
15
 
@@ -26,10 +26,6 @@ interface EventMinimal {
26
26
  // timeout_id : NodeJS.Timeout | null;
27
27
  // };
28
28
 
29
- const k_ERROR = -1;
30
- const k_NOP = 0;
31
- // const k_HANDLED = 1;
32
-
33
29
  const k_TTL= 20000;
34
30
 
35
31
  //-------------------------------------------------------------------------------------------------
@@ -52,7 +48,7 @@ LOGR_.labels= l_;
52
48
 
53
49
  //-------------------------------------------------------------------------------------------------
54
50
 
55
- type t_callback = (msg : t_msg, json_msg : JSON_Msg) => number;
51
+ type t_callback = (msg : t_msg, json_msg : JSON_Msg) => boolean;
56
52
  type t_callback_void = (msg : t_msg, json_msg : JSON_Msg) => void;
57
53
 
58
54
  class Config {
@@ -66,16 +62,16 @@ class Config {
66
62
  constructor() {
67
63
  // Initialize callbacks as no-op functions
68
64
  this._callback_msgWarp = (_msg : t_msg, _json_msg : JSON_Msg) => {
69
- console.assert(false, 'callback_msgWarp uninitialized'); return k_ERROR;
65
+ console.assert(false, 'callback_msgWarp uninitialized'); return false;
70
66
  };
71
67
  this._callback_msgEngage = (_msg : t_msg, _json_msg : JSON_Msg) => {
72
- console.assert(false, 'callback_msgEngage uninitialized'); return k_ERROR;
68
+ console.assert(false, 'callback_msgEngage uninitialized'); return false;
73
69
  };
74
70
  this._callback_msgAckWarp = (_msg : t_msg, _json_msg : JSON_Msg) => {
75
- console.assert(false, 'callback_msgAckWarp uninitialized'); return k_ERROR;
71
+ console.assert(false, 'callback_msgAckWarp uninitialized'); return false;
76
72
  };
77
73
  this._callback_msgAckEngage = (_msg : t_msg, _json_msg : JSON_Msg) => {
78
- console.assert(false, 'callback_msgAckEngage uninitialized'); return k_ERROR;
74
+ console.assert(false, 'callback_msgAckEngage uninitialized'); return false;
79
75
  };
80
76
  this._callback_msg_sent_expired = (_msg : t_msg, _json_msg : JSON_Msg) => {
81
77
  console.assert(false, '_callback_msg_sent_expired uninitialized');
@@ -117,7 +113,7 @@ class Config {
117
113
 
118
114
  //-------------------------------------------------------------------------------------------------
119
115
 
120
- let k_VERSION= "1";
116
+ let k_VERSION= "2";
121
117
 
122
118
  // rtt_msec <= ttl_msec *2 => rtt_msec = ttl_msec *2
123
119
  // t_ttl_rtt_(TTL, RTT) = t_ttl_rtt_(TTL, TTL *2) = TTL *2 + TTL *2 = TTL *4 MAX
@@ -134,8 +130,8 @@ function time_ttl_rtt_(ttl_msec: number | undefined, rtt_msec?: number): number
134
130
 
135
131
  var JSON_MsgOptions = (function() {
136
132
  return {
137
- create_with_msg_options : function(_msg, options) {
138
- return JSON_Msg_msg.create_with_msg_merge(_msg, {
133
+ create_with_cause_options : function(msg_cause, options) {
134
+ return JSON_MsgEffect.create_with_msg_merge(msg_cause, {
139
135
  options: options,
140
136
  "2PhW": k_VERSION
141
137
  });
@@ -190,9 +186,9 @@ var JSON_MsgWarp = (function() {
190
186
 
191
187
  var JSON_MsgEngage = (function() {
192
188
  return {
193
- create_with_MsgWarp : function(json_msgWarp) {
189
+ create_with_Warp : function(json_msgWarp) {
194
190
  console.assert(json_msgWarp.ack === undefined, "Engage with a Warp, not an Ack");
195
- return JSON_Msg_msg.create_with_msg_merge(json_msgWarp, {
191
+ return JSON_MsgEffect.create_with_cause_merge(json_msgWarp, {
196
192
  engage : {
197
193
  "ok" : true,
198
194
  "rtt_msec" : Date.now() - Date.parse(json_msgWarp.dt)
@@ -200,12 +196,12 @@ var JSON_MsgEngage = (function() {
200
196
  "2PhW": k_VERSION
201
197
  });
202
198
  },
203
- validate : function(json_msg_msg) {
199
+ validate : function(json_msgEffect) {
204
200
  // if (! JSON_Msg_msg.validate(json))
205
201
  // return false;
206
- if (! JSON_MsgWarp.validate(json_msg_msg._msg))
202
+ if (! JSON_MsgWarp.validate(json_msgEffect._cause))
207
203
  return false;
208
- if (! schema_MsgEngage_(json_msg_msg)) {
204
+ if (! schema_MsgEngage_(json_msgEffect)) {
209
205
  log_(l_.VALIDATION, () => ['JSON_MsgEngage: schema_MsgEngage_: ', (schema_MsgEngage_ as any).errors])
210
206
  return false;
211
207
  }
@@ -218,23 +214,23 @@ var JSON_MsgAckWarp = (function() {
218
214
  return {
219
215
  // createWith_msgAck_msg : function(json_msgAck, _msg) {
220
216
  // const json_msgAckWarp= structuredClone(json_msgAck);
221
- // json_msgAckWarp._msg= _msg;
217
+ // json_msgAckWarp._cause= _cause;
222
218
  // return json_msgAckWarp;
223
219
  // }
224
- create_with_msgOk : function(json_msgWarp, b_ok= true) {
225
- const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgOk(json_msgWarp, b_ok);
226
- json_msgAck_msg["2PhW"]= k_VERSION;
227
- return json_msgAck_msg;
220
+ create_with_Warp_Ok : function(json_msgWarp, b_ok= true) {
221
+ const json_msgAck= JSON_MsgAck.create_with_cause_Ok(json_msgWarp, b_ok);
222
+ json_msgAck["2PhW"]= k_VERSION;
223
+ return json_msgAck;
228
224
  },
229
225
  // create_with_msgExpired : function( json_msgWarp ) {
230
226
  // const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgWarp )
231
227
  // json_msgAck_msg["2PhW"]= k_VERSION;
232
228
  // return json_msgAck_msg;
233
229
  // },
234
- validate : function(json_msgAck_msg) {
230
+ validate : function(json_msgAck) {
235
231
  // if (! JSON_MsgAck_msg.validate(json))
236
232
  // return false;
237
- if (! JSON_MsgWarp.validate(json_msgAck_msg._msg))
233
+ if (! JSON_MsgWarp.validate(json_msgAck._cause))
238
234
  return false;
239
235
  return true;
240
236
  }
@@ -245,23 +241,23 @@ var JSON_MsgAckEngage = (function() {
245
241
  return {
246
242
  // createWith_msgAck_msg : function(json_msgAck, _msg) {
247
243
  // const json_msgAckEngage= structuredClone(json_msgAck);
248
- // json_msgAckEngage._msg= _msg;
244
+ // json_msgAckEngage._cause= _cause;
249
245
  // return json_msgAckEngage;
250
246
  // }
251
- create_with_msgOk : function(json_msgEngage, b_ok= true) {
252
- const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgOk(json_msgEngage, b_ok);
253
- json_msgAck_msg["2PhW"]= k_VERSION;
254
- return json_msgAck_msg;
247
+ create_with_Engage_Ok : function(json_msgEngage, b_ok= true) {
248
+ const json_msgAck= JSON_MsgAck.create_with_cause_Ok(json_msgEngage, b_ok);
249
+ json_msgAck["2PhW"]= k_VERSION;
250
+ return json_msgAck;
255
251
  },
256
252
  // create_with_msgExpired : function( json_msgEngage ) {
257
253
  // const json_msgAck_msg= JSON_MsgAck_msg.create_with_msgExpired( json_msgEngage )
258
254
  // json_msgAck_msg["2PhW"]= k_VERSION;
259
255
  // return json_msgAck_msg;
260
256
  // },
261
- validate : function(json_msgAck_msg) {
257
+ validate : function(json_msgAck) {
262
258
  // if (! JSON_MsgAck_msg.validate(json_msgAck_msg))
263
259
  // return false;
264
- if (! JSON_MsgEngage.validate(json_msgAck_msg._msg))
260
+ if (! JSON_MsgEngage.validate(json_msgAck._cause))
265
261
  return false;
266
262
  return true;
267
263
  }
@@ -325,7 +321,7 @@ class StateEngage extends StateState {
325
321
  return false;
326
322
 
327
323
  // The Engage gets to live for THE WARP'S creation time + TTL*2 + RTT
328
- const json_msgWarp= this.json_msgEngage._msg;
324
+ const json_msgWarp= this.json_msgEngage._cause;
329
325
  const timeout_ms= time_ttl_rtt_(json_msgWarp.warp.ttl_msec, this.json_msgEngage.engage.rtt_msec);
330
326
  log_(l_.PROTOCOL_STATE, () => [`StateEngage: evt_AckEngage.dt@${state_new.evt_AckEngage.dt}, msgWarp.dt@${Date.parse(json_msgWarp.dt)} + ${timeout_ms}`])
331
327
  if (state_new.evt_AckEngage.dt >= Date.parse(json_msgWarp.dt) + timeout_ms)
@@ -346,7 +342,7 @@ class StateAckWarp extends StateState {
346
342
  if (! this.json_msgAckWarp.ack.ok)
347
343
  return false;
348
344
 
349
- if (this.json_msgAckWarp._msg.warp.instantaneous)
345
+ if (this.json_msgAckWarp._cause.warp.instantaneous)
350
346
  return false;
351
347
 
352
348
  // The Ack gets to live for THE ACK'S creation time + TTL*2 + STT
@@ -354,7 +350,7 @@ class StateAckWarp extends StateState {
354
350
  // - Engage: T0 +2TTL +RTT; RTT= STT+STT
355
351
  // - AckWarp: TAckWarp +2TLL +STT; TAckWarp= T0 +STT;
356
352
  // - STT: Date of the Ack minus date of the Warp.
357
- const timeout_ms= time_ttl_rtt_(this.json_msgAckWarp._msg.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._msg.dt);
353
+ const timeout_ms= time_ttl_rtt_(this.json_msgAckWarp._cause.warp.ttl_msec) + Date.parse(this.json_msgAckWarp.dt) - Date.parse(this.json_msgAckWarp._cause.dt);
358
354
  log_(l_.PROTOCOL_STATE, () => [`StateAckWarp: evt_Engage.dt@${state_new.evt_Engage.dt}, msgAckWarp.dt@${Date.parse(this.json_msgAckWarp.dt)} + ${timeout_ms}`])
359
355
  if (state_new.evt_Engage.dt >= Date.parse(this.json_msgAckWarp.dt) + timeout_ms)
360
356
  return false;
@@ -443,7 +439,7 @@ class TwoPhW_EventLog {
443
439
 
444
440
  _warp(json_msg) {
445
441
  const b_Ack = json_msg.ack !== undefined;
446
- const json = b_Ack ? json_msg["_msg"] : json_msg;
442
+ const json = b_Ack ? json_msg["_cause"] : json_msg;
447
443
 
448
444
  if (json.warp) {
449
445
  return {
@@ -454,7 +450,7 @@ class TwoPhW_EventLog {
454
450
  if (json.engage) {
455
451
  return {
456
452
  str_type: `2PhW[JSON_Msg${b_Ack ? 'Ack' : ''}Engage]`,
457
- json_msgWarp: json["_msg"]
453
+ json_msgWarp: json["_cause"]
458
454
  };
459
455
  }
460
456
  return { str_type: null, json_msgWarp: null }; // Explicit default for invalid cases
@@ -540,7 +536,7 @@ class TwoPhW {
540
536
 
541
537
  //-------------------------------------------------------------------------------------------------
542
538
 
543
- _handler_msgOptions(cfg, msg, json_msgOptions) : number
539
+ _handler_msgOptions(cfg, msg, json_msgOptions) : boolean
544
540
  {
545
541
  log_(l_.HANDLERS, () => ['handler_msgOptions_: ...']);
546
542
 
@@ -548,8 +544,8 @@ class TwoPhW {
548
544
  if (! validate_Options_delay_(json_msgOptions.options))
549
545
  return false;
550
546
 
551
- if (JSON_MsgWarp.validate(json_msgOptions._msg)) {
552
- const json_msgWarp= json_msgOptions._msg;
547
+ if (JSON_MsgWarp.validate(json_msgOptions._cause)) {
548
+ const json_msgWarp= json_msgOptions._cause;
553
549
 
554
550
  const ctx= get_ctx(json_msgWarp.id);
555
551
  if (!ctx )
@@ -571,13 +567,13 @@ class TwoPhW {
571
567
  }
572
568
  */
573
569
 
574
- return k_NOP;
570
+ return false;
575
571
  }
576
572
 
577
573
  //-------------------------------------------------------------------------------------------------
578
574
  // sender Source (src)
579
575
 
580
- register_msgWarp(msg : t_msg, json_msgWarp : JSON_Msg) : number
576
+ register_msgWarp(msg : t_msg, json_msgWarp : JSON_Msg) : boolean
581
577
  {
582
578
  log_(l_.SENDER, () => ['register_msgWarp: ', json_msgWarp]);
583
579
 
@@ -589,7 +585,7 @@ class TwoPhW {
589
585
 
590
586
  log_(l_.HANDLERS | l_.SENDER, () => ['register_msgWarp: protocolState.canChangeState ', b_changeState]);
591
587
  if (! b_changeState)
592
- return k_NOP;
588
+ return false;
593
589
 
594
590
  const timeout_ms= time_ttl_rtt_(json_msgWarp.warp.ttl_msec);
595
591
  const elapsed_ms= Date.now() - Date.parse(json_msgWarp.dt);
@@ -599,11 +595,11 @@ class TwoPhW {
599
595
  });
600
596
  }
601
597
 
602
- _handler_msgAckWarp(msg : t_msg, json_msgAckWarp : JSON_MsgAck_msg) : number
598
+ _handler_msgAckWarp(msg : t_msg, json_msgAckWarp : JSON_MsgAck) : boolean
603
599
  {
604
600
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: ', json_msgAckWarp]);
605
601
 
606
- const json_msgWarp= json_msgAckWarp._msg;
602
+ const json_msgWarp= json_msgAckWarp._cause;
607
603
 
608
604
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
609
605
  const b_changeState= protocolState.canChangeState( new StateAckWarp(null, {
@@ -613,18 +609,18 @@ class TwoPhW {
613
609
 
614
610
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckWarp: protocolState.canChangeState ', b_changeState]);
615
611
  if (! b_changeState)
616
- return k_NOP;
612
+ return false;
617
613
 
618
614
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
619
615
  this.eventLog._addEvent(msg, json_msgAckWarp);
620
616
  return this.config._callback_msgAckWarp(msg, json_msgAckWarp);
621
617
  }
622
618
 
623
- register_msgEngage(msg : t_msg, json_msgEngage : JSON_Msg_msg) : number
619
+ register_msgEngage(msg : t_msg, json_msgEngage : JSON_MsgEffect) : boolean
624
620
  {
625
621
  log_(l_.SENDER, () => ['register_msgEngage: ', json_msgEngage]);
626
622
 
627
- const json_msgWarp= json_msgEngage._msg;
623
+ const json_msgWarp= json_msgEngage._cause;
628
624
 
629
625
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
630
626
  const b_changeState = protocolState.canChangeState( new StateEngage(null, {
@@ -634,7 +630,7 @@ class TwoPhW {
634
630
 
635
631
  log_(l_.HANDLERS | l_.SENDER, () => ['register_msgEngage: protocolState.canChangeState ', b_changeState]);
636
632
  if (! b_changeState)
637
- return k_NOP;
633
+ return false;
638
634
 
639
635
  const timeout_ms= time_ttl_rtt_(json_msgWarp.warp.ttl_msec, json_msgEngage.engage.rtt_msec);
640
636
  const elapsed_ms= Date.now() - Date.parse(json_msgWarp.dt);
@@ -644,11 +640,11 @@ class TwoPhW {
644
640
  });
645
641
  }
646
642
 
647
- _handler_msgAckEngage(msg : t_msg, json_msgAckEngage : JSON_MsgAck_msg) : number
643
+ _handler_msgAckEngage(msg : t_msg, json_msgAckEngage : JSON_MsgAck) : boolean
648
644
  {
649
645
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage: ', json_msgAckEngage]);
650
646
 
651
- const json_msgWarp= json_msgAckEngage._msg._msg;
647
+ const json_msgWarp= json_msgAckEngage._cause._cause;
652
648
 
653
649
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
654
650
  const b_changeState= protocolState.canChangeState( new StateAckEngage(null, {
@@ -658,7 +654,7 @@ class TwoPhW {
658
654
 
659
655
  log_(l_.HANDLERS | l_.SENDER, () => ['handler_msgAckEngage_: protocolState.canChangeState ', b_changeState]);
660
656
  if (! b_changeState)
661
- return k_NOP;
657
+ return false;
662
658
 
663
659
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
664
660
  this.eventLog._addEvent(msg, json_msgAckEngage);
@@ -668,7 +664,7 @@ class TwoPhW {
668
664
  //-------------------------------------------------------------------------------------------------
669
665
  // receiver Destination (dst)
670
666
 
671
- _handler_msgWarp(msg : t_msg, json_msgWarp : JSON_Msg) : number
667
+ _handler_msgWarp(msg : t_msg, json_msgWarp : JSON_Msg) : boolean
672
668
  {
673
669
  log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: ', json_msgWarp]);
674
670
 
@@ -680,17 +676,17 @@ class TwoPhW {
680
676
 
681
677
  log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgWarp: protocolState.canChangeState: ', b_changeState]);
682
678
  if (! b_changeState)
683
- return k_NOP;
679
+ return false;
684
680
 
685
681
  this.eventLog._addEvent(msg, json_msgWarp);
686
682
  return this.config._callback_msgWarp(msg, json_msgWarp)
687
683
  }
688
684
 
689
- register_msgAckWarp(msg: t_msg, json_msgAckWarp : JSON_MsgAck_msg) : number
685
+ register_msgAckWarp(msg: t_msg, json_msgAckWarp : JSON_MsgAck) : boolean
690
686
  {
691
687
  log_(l_.RECVER, () => ['register_msgAckWarp: ', json_msgAckWarp]);
692
688
 
693
- const json_msgWarp= json_msgAckWarp._msg;
689
+ const json_msgWarp= json_msgAckWarp._cause;
694
690
 
695
691
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
696
692
  const b_changeState= protocolState.canChangeState( new StateAckWarp(null, {
@@ -700,7 +696,7 @@ class TwoPhW {
700
696
 
701
697
  log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckWarp: protocolState.canChangeState: ', b_changeState]);
702
698
  if (! b_changeState)
703
- return k_NOP;
699
+ return false;
704
700
 
705
701
  const elapsed_ms= Date.now() - Date.parse(json_msgAckWarp.dt);
706
702
  const timeout_ms= time_ttl_rtt_(json_msgWarp.warp.ttl_msec) + Date.parse(json_msgAckWarp.dt) - Date.parse(json_msgWarp.dt);
@@ -710,11 +706,11 @@ class TwoPhW {
710
706
  });
711
707
  }
712
708
 
713
- _handler_msgEngage(msg : t_msg, json_msgEngage : JSON_Msg_msg) : number
709
+ _handler_msgEngage(msg : t_msg, json_msgEngage : JSON_MsgEffect) : boolean
714
710
  {
715
711
  log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: ', json_msgEngage]);
716
712
 
717
- const json_msgWarp= json_msgEngage["_msg"];
713
+ const json_msgWarp= json_msgEngage._cause;
718
714
 
719
715
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
720
716
  const b_changeState= protocolState.canChangeState( new StateEngage(null, {
@@ -724,18 +720,18 @@ class TwoPhW {
724
720
 
725
721
  log_(l_.HANDLERS | l_.RECVER, () => ['handler_msgEngage: protocolState.canChangeState: ', b_changeState]);
726
722
  if (! b_changeState)
727
- return k_NOP;
723
+ return false;
728
724
 
729
725
  this.eventLog._cancelTimeout(protocolState.state.idx_event);
730
726
  this.eventLog._addEvent(msg, json_msgEngage);
731
727
  return this.config._callback_msgEngage(msg, json_msgEngage)
732
728
  }
733
729
 
734
- register_msgAckEngage(msg : t_msg, json_msgAckEngage : JSON_MsgAck_msg) : number
730
+ register_msgAckEngage(msg : t_msg, json_msgAckEngage : JSON_MsgAck) : boolean
735
731
  {
736
732
  log_(l_.RECVER, () => ['register_msgAckEngage: ', json_msgAckEngage]);
737
733
 
738
- const json_msgWarp= json_msgAckEngage._msg._msg;
734
+ const json_msgWarp= json_msgAckEngage._cause._cause;
739
735
 
740
736
  const protocolState= this.eventLog.traverse_State(json_msgWarp);
741
737
  const b_changeState= protocolState.canChangeState( new StateAckEngage(null, {
@@ -745,51 +741,48 @@ class TwoPhW {
745
741
 
746
742
  log_(l_.HANDLERS | l_.RECVER, () => ['register_msgAckEngage: protocolState.canChangeState: ', b_changeState]);
747
743
  if (! b_changeState)
748
- return k_NOP;
744
+ return false;
749
745
 
750
746
  this.eventLog._addEvent(msg, json_msgAckEngage);
751
747
  }
752
748
 
753
749
  //-------------------------------------------------------------------------------------------------
754
750
 
755
- handler_json_msgAck_msg(msg : t_msg, json_msgAck_msg : JSON_MsgAck_msg) : number
751
+ handler_json_msgAck(msg : t_msg, json_msgAck : JSON_MsgAck) : boolean
756
752
  {
757
- log_(l_.HANDLERS, () => ['handler_json_msgAck_msg: ', json_msgAck_msg]);
753
+ log_(l_.HANDLERS, () => ['handler_json_msgAck: ', json_msgAck]);
758
754
 
759
- let ret : number;
760
-
761
- if (JSON_MsgAckWarp.validate(json_msgAck_msg) && (ret= this._handler_msgAckWarp(msg, json_msgAck_msg)) )
762
- return ret;
755
+ if (JSON_MsgAckWarp.validate(json_msgAck) && this._handler_msgAckWarp(msg, json_msgAck) )
756
+ return true;
763
757
 
764
- if (JSON_MsgAckEngage.validate(json_msgAck_msg) && (ret= this._handler_msgAckEngage(msg, json_msgAck_msg)) )
765
- return ret;
758
+ if (JSON_MsgAckEngage.validate(json_msgAck) && this._handler_msgAckEngage(msg, json_msgAck) )
759
+ return true;
766
760
 
767
- return k_NOP;
761
+ return false;
768
762
  }
769
763
 
770
- handler_json_msg_msg(msg : t_msg, json_msg_msg : JSON_Msg_msg) : number
764
+ handler_json_msgEffect(msg : t_msg, json_msgEffect : JSON_MsgEffect) : boolean
771
765
  {
772
- log_(l_.HANDLERS, () => ['handler_json_msg_msg: ', json_msg_msg]);
766
+ log_(l_.HANDLERS, () => ['handler_json_msgEffect: ', json_msgEffect]);
773
767
 
774
- let ret : number;
768
+ if (JSON_MsgAck.validate(json_msgEffect) && this.handler_json_msgAck(msg, json_msgEffect) )
769
+ return true;
775
770
 
776
- if (JSON_MsgEngage.validate(json_msg_msg) && (ret= this._handler_msgEngage(msg, json_msg_msg)) )
777
- return ret;
771
+ if (JSON_MsgEngage.validate(json_msgEffect) && this._handler_msgEngage(msg, json_msgEffect) )
772
+ return true;
778
773
 
779
774
  // if (JSON_MsgOptions.validate(json_msg) && this.handler_msgOptions_(this._config, msg, json_msg))
780
775
  // return true;
781
776
 
782
- return k_NOP;
777
+ return false;
783
778
  }
784
779
 
785
- handler_json_msg(msg : t_msg, json_msg : JSON_Msg) : number
780
+ handler_json_msg(msg : t_msg, json_msg : JSON_Msg) : boolean
786
781
  {
787
782
  log_(l_.HANDLERS, () => ['handler_json_msg: ', json_msg]);
788
783
 
789
- let ret : number;
790
-
791
- if (JSON_MsgWarp.validate(json_msg) && (ret= this._handler_msgWarp(msg, json_msg)) )
792
- return ret;
784
+ if (JSON_MsgWarp.validate(json_msg) && this._handler_msgWarp(msg, json_msg) )
785
+ return true;
793
786
 
794
787
  // https://attacomsian.com/blog/javascript-iterate-objects
795
788
  // Object.keys(json_msg).forEach((key, index) => {
@@ -800,43 +793,20 @@ class TwoPhW {
800
793
  // console.log(`${key}: ${json_msg[key]}`);
801
794
  // });
802
795
 
803
- return k_NOP;
796
+ return false;
804
797
  }
805
798
 
806
- handler_json(msg : t_msg, json) : number
799
+ handler_json(msg : t_msg, json) : boolean
807
800
  {
808
- if (JSON_Msg.validate(json))
809
- {
810
- if (JSON_Msg_msg.validate(json))
811
- {
812
- if (JSON_MsgAck_msg.validate(json))
813
- {
814
- let ret : number;
815
-
816
- if (JSON_MsgAckWarp.validate(json) && (ret= this._handler_msgAckWarp(msg, json)) )
817
- return ret;
818
-
819
- if (JSON_MsgAckEngage.validate(json) && (ret= this._handler_msgAckEngage(msg, json)) )
820
- return ret;
821
-
822
- return k_NOP;
823
- }
824
-
825
- let ret : number;
826
- if (JSON_MsgEngage.validate(json) && (ret= this._handler_msgEngage(msg, json)) )
827
- return ret;
828
-
829
- return k_NOP;
830
- }
801
+ log_(l_.HANDLERS, () => ['handler_json: ', json]);
831
802
 
832
- let ret : number;
833
- if (JSON_MsgWarp.validate(json) && (ret= this._handler_msgWarp(msg, json)) )
834
- return ret;
803
+ if (JSON_MsgEffect.validate(json) && this.handler_json_msgEffect(msg, json) )
804
+ return true;
835
805
 
836
- return k_NOP;
837
- }
806
+ if (JSON_Msg.validate(json) && this.handler_json_msg(msg, json) )
807
+ return true;
838
808
 
839
- return k_NOP;
809
+ return false;
840
810
  }
841
811
 
842
812
  };
@@ -1 +1 @@
1
- "use strict";export const definitions_2PhW = validate18;const schema21 = {"$id":"https://root-interface.se/protocols/2PhW/definitions","$schema":"https://json-schema.org/draft/2019-09/schema","definitions":{"2PhW":{"const":"1"},"warp_id":{"type":"string"}}};function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/definitions" */;validate18.errors = null;return true;}validate18.evaluated = {"dynamicProps":false,"dynamicItems":false};export const schema_MsgWarp = validate19;const schema22 = {"$id":"https://root-interface.se/protocols/2PhW/MsgWarp","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["id","user","hyperport","ttl_msec"],"properties":{"id":{"$ref":"definitions#/definitions/warp_id"},"ttl_msec":{"type":"integer"},"instantaneous":{"type":"boolean"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};const schema23 = {"type":"string"};const schema24 = {"const":"1"};function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgWarp" */;let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))){validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.id !== undefined){const _errs3 = errors;if(typeof data0.id !== "string"){validate19.errors = [{instancePath:instancePath+"/warp/id",schemaPath:"definitions#/definitions/warp_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.ttl_msec !== undefined){let data2 = data0.ttl_msec;const _errs6 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate19.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs6 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs8 = errors;if(typeof data0.instantaneous !== "boolean"){validate19.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs8 === errors;}else {var valid1 = true;}}}}}else {validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs10 = errors;if("1" !== data["2PhW"]){validate19.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs10 === errors;}else {var valid0 = true;}}}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"props":{"warp":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgEngage = validate20;const schema25 = {"$id":"https://root-interface.se/protocols/2PhW/MsgEngage","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["ok","rtt_msec"],"properties":{"ok":{"type":"boolean"},"rtt_msec":{"type":"integer"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgEngage" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))){validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){const _errs3 = errors;if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/engage/ok",schemaPath:"#/properties/engage/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.rtt_msec !== undefined){let data2 = data0.rtt_msec;const _errs5 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate20.errors = [{instancePath:instancePath+"/engage/rtt_msec",schemaPath:"#/properties/engage/properties/rtt_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs7 = errors;if("1" !== data["2PhW"]){validate20.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "1"},message:"must be equal to constant"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"engage":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};
1
+ "use strict";export const definitions_2PhW = validate18;const schema21 = {"$id":"https://root-interface.se/protocols/2PhW/definitions","$schema":"https://json-schema.org/draft/2019-09/schema","definitions":{"2PhW":{"const":"2"},"warp_id":{"type":"string"}}};function validate18(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/definitions" */;validate18.errors = null;return true;}validate18.evaluated = {"dynamicProps":false,"dynamicItems":false};export const schema_MsgWarp = validate19;const schema22 = {"$id":"https://root-interface.se/protocols/2PhW/MsgWarp","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["warp"],"properties":{"warp":{"type":"object","required":["id","user","hyperport","ttl_msec"],"properties":{"id":{"$ref":"definitions#/definitions/warp_id"},"ttl_msec":{"type":"integer"},"instantaneous":{"type":"boolean"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};const schema23 = {"type":"string"};const schema24 = {"const":"2"};function validate19(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgWarp" */;let vErrors = null;let errors = 0;const evaluated0 = validate19.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.warp === undefined) && (missing0 = "warp")){validate19.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.warp !== undefined){let data0 = data.warp;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((((data0.id === undefined) && (missing1 = "id")) || ((data0.user === undefined) && (missing1 = "user"))) || ((data0.hyperport === undefined) && (missing1 = "hyperport"))) || ((data0.ttl_msec === undefined) && (missing1 = "ttl_msec"))){validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.id !== undefined){const _errs3 = errors;if(typeof data0.id !== "string"){validate19.errors = [{instancePath:instancePath+"/warp/id",schemaPath:"definitions#/definitions/warp_id/type",keyword:"type",params:{type: "string"},message:"must be string"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.ttl_msec !== undefined){let data2 = data0.ttl_msec;const _errs6 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate19.errors = [{instancePath:instancePath+"/warp/ttl_msec",schemaPath:"#/properties/warp/properties/ttl_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs6 === errors;}else {var valid1 = true;}if(valid1){if(data0.instantaneous !== undefined){const _errs8 = errors;if(typeof data0.instantaneous !== "boolean"){validate19.errors = [{instancePath:instancePath+"/warp/instantaneous",schemaPath:"#/properties/warp/properties/instantaneous/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs8 === errors;}else {var valid1 = true;}}}}}else {validate19.errors = [{instancePath:instancePath+"/warp",schemaPath:"#/properties/warp/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs10 = errors;if("2" !== data["2PhW"]){validate19.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "2"},message:"must be equal to constant"}];return false;}var valid0 = _errs10 === errors;}else {var valid0 = true;}}}}else {validate19.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate19.errors = vErrors;return errors === 0;}validate19.evaluated = {"props":{"warp":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};export const schema_MsgEngage = validate20;const schema25 = {"$id":"https://root-interface.se/protocols/2PhW/MsgEngage","$schema":"https://json-schema.org/draft/2019-09/schema","type":"object","required":["engage"],"properties":{"engage":{"type":"object","required":["ok","rtt_msec"],"properties":{"ok":{"type":"boolean"},"rtt_msec":{"type":"integer"}}},"2PhW":{"$ref":"definitions#/definitions/2PhW"}}};function validate20(data, {instancePath="", parentData, parentDataProperty, rootData=data, dynamicAnchors={}}={}){/*# sourceURL="https://root-interface.se/protocols/2PhW/MsgEngage" */;let vErrors = null;let errors = 0;const evaluated0 = validate20.evaluated;if(evaluated0.dynamicProps){evaluated0.props = undefined;}if(evaluated0.dynamicItems){evaluated0.items = undefined;}if(errors === 0){if(data && typeof data == "object" && !Array.isArray(data)){let missing0;if((data.engage === undefined) && (missing0 = "engage")){validate20.errors = [{instancePath,schemaPath:"#/required",keyword:"required",params:{missingProperty: missing0},message:"must have required property '"+missing0+"'"}];return false;}else {if(data.engage !== undefined){let data0 = data.engage;const _errs1 = errors;if(errors === _errs1){if(data0 && typeof data0 == "object" && !Array.isArray(data0)){let missing1;if(((data0.ok === undefined) && (missing1 = "ok")) || ((data0.rtt_msec === undefined) && (missing1 = "rtt_msec"))){validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/required",keyword:"required",params:{missingProperty: missing1},message:"must have required property '"+missing1+"'"}];return false;}else {if(data0.ok !== undefined){const _errs3 = errors;if(typeof data0.ok !== "boolean"){validate20.errors = [{instancePath:instancePath+"/engage/ok",schemaPath:"#/properties/engage/properties/ok/type",keyword:"type",params:{type: "boolean"},message:"must be boolean"}];return false;}var valid1 = _errs3 === errors;}else {var valid1 = true;}if(valid1){if(data0.rtt_msec !== undefined){let data2 = data0.rtt_msec;const _errs5 = errors;if(!(((typeof data2 == "number") && (!(data2 % 1) && !isNaN(data2))) && (isFinite(data2)))){validate20.errors = [{instancePath:instancePath+"/engage/rtt_msec",schemaPath:"#/properties/engage/properties/rtt_msec/type",keyword:"type",params:{type: "integer"},message:"must be integer"}];return false;}var valid1 = _errs5 === errors;}else {var valid1 = true;}}}}else {validate20.errors = [{instancePath:instancePath+"/engage",schemaPath:"#/properties/engage/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}var valid0 = _errs1 === errors;}else {var valid0 = true;}if(valid0){if(data["2PhW"] !== undefined){const _errs7 = errors;if("2" !== data["2PhW"]){validate20.errors = [{instancePath:instancePath+"/2PhW",schemaPath:"definitions#/definitions/2PhW/const",keyword:"const",params:{allowedValue: "2"},message:"must be equal to constant"}];return false;}var valid0 = _errs7 === errors;}else {var valid0 = true;}}}}else {validate20.errors = [{instancePath,schemaPath:"#/type",keyword:"type",params:{type: "object"},message:"must be object"}];return false;}}validate20.errors = vErrors;return errors === 0;}validate20.evaluated = {"props":{"engage":true,"2PhW":true},"dynamicProps":false,"dynamicItems":false};