relayx-js 1.0.13 → 1.0.14
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/README.md +1 -4
- package/package.json +6 -7
- package/realtime/realtime.js +12 -14
package/README.md
CHANGED
|
@@ -22,9 +22,7 @@ Install the relay library by running the command below in your terminal<br>
|
|
|
22
22
|
api_key: process.env.api_key,
|
|
23
23
|
secret: process.env.secret,
|
|
24
24
|
});
|
|
25
|
-
realtime.init(
|
|
26
|
-
browser_mode: true // Enable when using in webapps
|
|
27
|
-
});
|
|
25
|
+
realtime.init();
|
|
28
26
|
|
|
29
27
|
// Initialization of topic listeners go here... (look at examples/example_chat.js for full implementation)
|
|
30
28
|
|
|
@@ -160,7 +158,6 @@ This event is fired when the library resends the messages upon reconnection to t
|
|
|
160
158
|
1. init()<br>
|
|
161
159
|
Initializes library with configuration options.
|
|
162
160
|
* debug (boolean): enables library level logging
|
|
163
|
-
* browser_mode (boolean): Allows websocket connections to be made from a browser. Default is TCP
|
|
164
161
|
2. connect()<br>
|
|
165
162
|
Connects the library to the Relay Network. This is an async function.
|
|
166
163
|
3. close()<br>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relayx-js",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"main": "realtime/realtime.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -17,12 +17,11 @@
|
|
|
17
17
|
"license": "Apache 2.0",
|
|
18
18
|
"description": "A powerful library for integrating real-time communication into your software stack, powered by the Relay Network.",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@msgpack/msgpack": "
|
|
21
|
-
"@nats-io/jetstream": "
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"uuid": "^11.1.0"
|
|
20
|
+
"@msgpack/msgpack": "3.1.1",
|
|
21
|
+
"@nats-io/jetstream": "3.0.0-35",
|
|
22
|
+
"jest": "29.7.0",
|
|
23
|
+
"nats": "2.28.2",
|
|
24
|
+
"uuid": "11.1.0"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"@babel/core": "^7.26.0",
|
package/realtime/realtime.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
1
|
import { connect, JSONCodec, Events, DebugEvents, AckPolicy, ReplayPolicy, credsAuthenticator } from "nats";
|
|
3
2
|
import { DeliverPolicy, jetstream } from "@nats-io/jetstream";
|
|
4
3
|
import { encode, decode } from "@msgpack/msgpack";
|
|
@@ -110,13 +109,6 @@ export class Realtime {
|
|
|
110
109
|
this.staging = staging;
|
|
111
110
|
this.opts = opts;
|
|
112
111
|
|
|
113
|
-
var browserMode = this.opts["browser_mode"];
|
|
114
|
-
var protocol = "tls"
|
|
115
|
-
|
|
116
|
-
if(browserMode != null && browserMode != undefined && (typeof browserMode == "boolean")){
|
|
117
|
-
protocol = browserMode ? "wss" : "tls"
|
|
118
|
-
}
|
|
119
|
-
|
|
120
112
|
if (staging !== undefined || staging !== null){
|
|
121
113
|
this.#baseUrl = staging ? [
|
|
122
114
|
"nats://0.0.0.0:4221",
|
|
@@ -124,15 +116,15 @@ export class Realtime {
|
|
|
124
116
|
"nats://0.0.0.0:4223"
|
|
125
117
|
] :
|
|
126
118
|
[
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
`tls://api.relay-x.io:4221`,
|
|
120
|
+
`tls://api.relay-x.io:4222`,
|
|
121
|
+
`tls://api.relay-x.io:4223`
|
|
130
122
|
];
|
|
131
123
|
}else{
|
|
132
124
|
this.#baseUrl = [
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
125
|
+
`tls://api.relay-x.io:4221`,
|
|
126
|
+
`tls://api.relay-x.io:4222`,
|
|
127
|
+
`tls://api.relay-x.io:4223`
|
|
136
128
|
];
|
|
137
129
|
}
|
|
138
130
|
|
|
@@ -216,6 +208,12 @@ export class Realtime {
|
|
|
216
208
|
this.#log("the connection closed!");
|
|
217
209
|
|
|
218
210
|
this.#offlineMessageBuffer.length = 0;
|
|
211
|
+
|
|
212
|
+
if (DISCONNECTED in this.#event_func){
|
|
213
|
+
if (this.#event_func[DISCONNECTED] !== null || this.#event_func[DISCONNECTED] !== undefined){
|
|
214
|
+
this.#event_func[DISCONNECTED]()
|
|
215
|
+
}
|
|
216
|
+
}
|
|
219
217
|
});
|
|
220
218
|
|
|
221
219
|
(async () => {
|