relayx-js 1.0.1 → 1.0.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/examples/example_chat.js
CHANGED
|
@@ -7,13 +7,11 @@ const rl = readline.createInterface({
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
async function run(){
|
|
10
|
-
// await throttle.start(options["fois"]);
|
|
11
|
-
|
|
12
10
|
var realtime = new Realtime({
|
|
13
11
|
api_key: process.env.user_key,
|
|
14
12
|
secret: process.env.secret
|
|
15
13
|
});
|
|
16
|
-
await realtime.init({
|
|
14
|
+
await realtime.init(true, {
|
|
17
15
|
max_retries: 2,
|
|
18
16
|
debug: true
|
|
19
17
|
});
|
|
@@ -7,7 +7,7 @@ async function run(){
|
|
|
7
7
|
});
|
|
8
8
|
await realtime.init(true, {
|
|
9
9
|
max_retries: 2,
|
|
10
|
-
debug: true
|
|
10
|
+
// debug: true
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
realtime.on(CONNECTED, async () => {
|
|
@@ -18,10 +18,17 @@ async function run(){
|
|
|
18
18
|
var value = Math.floor(Math.random() * (100 + 1))
|
|
19
19
|
console.log(value)
|
|
20
20
|
|
|
21
|
-
await realtime.publish("test-
|
|
21
|
+
// await realtime.publish("test-power-1", {
|
|
22
|
+
// "value": value,
|
|
23
|
+
// "time": Date.now() + 2000
|
|
24
|
+
// })
|
|
25
|
+
|
|
26
|
+
var sent = await realtime.publish("power-telemetry", {
|
|
22
27
|
"value": value,
|
|
23
|
-
"time": Date.now()
|
|
24
|
-
})
|
|
28
|
+
"time": Date.now()
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log(`Message sent => ${sent}`);
|
|
25
32
|
|
|
26
33
|
await realtime.sleep(100)
|
|
27
34
|
}
|
package/package.json
CHANGED
package/realtime/realtime.js
CHANGED
|
@@ -69,7 +69,7 @@ export class Realtime {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
/*
|
|
72
|
-
|
|
72
|
+
Initializes library with configuration options.
|
|
73
73
|
*/
|
|
74
74
|
async init(staging, opts){
|
|
75
75
|
/**
|
|
@@ -145,7 +145,7 @@ export class Realtime {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* Gets the namespace of the user using a
|
|
148
|
+
* Gets the namespace of the user using a micro service
|
|
149
149
|
* @returns {string} namespace value. Null if failed to retreive
|
|
150
150
|
*/
|
|
151
151
|
async #getNameSpace() {
|
|
@@ -483,6 +483,8 @@ export class Realtime {
|
|
|
483
483
|
filter_subjects: [this.#getStreamTopic(topic), this.#getStreamTopic(topic) + "_presence"],
|
|
484
484
|
replay_policy: ReplayPolicy.Instant,
|
|
485
485
|
opt_start_time: new Date(),
|
|
486
|
+
ack_policy: AckPolicy.Explicit,
|
|
487
|
+
delivery_policy: DeliverPolicy.New
|
|
486
488
|
}
|
|
487
489
|
|
|
488
490
|
const consumer = await this.#jetstream.consumers.get(this.#getStreamName(), opts);
|
|
@@ -560,8 +562,6 @@ export class Realtime {
|
|
|
560
562
|
await this.#jsManager.streams.add({
|
|
561
563
|
name: streamName,
|
|
562
564
|
subjects: [...this.#getStreamTopicList(), ...this.#getPresenceTopics()],
|
|
563
|
-
ack_policy: AckPolicy.Explicit,
|
|
564
|
-
delivery_policy: DeliverPolicy.New
|
|
565
565
|
});
|
|
566
566
|
|
|
567
567
|
this.#log(`${streamName} created`);
|