You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lazer/sdk/js/examples/index.ts
+67-64Lines changed: 67 additions & 64 deletions
Original file line number
Diff line number
Diff line change
@@ -7,78 +7,81 @@ import { PythLazerClient } from "../src/index.js";
7
7
console.debug=()=>{};
8
8
9
9
asyncfunctionmain(){
10
-
try{
11
-
constclient=awaitPythLazerClient.create(
12
-
["wss://pyth-lazer.dourolabs.app/v1/stream"],
13
-
"access_token",
14
-
3,// Optionally specify number of parallel redundant connections to reduce the chance of dropped messages. The connections will round-robin across the provided URLs. Default is 3.
15
-
console// Optionally log socket operations (to the console in this case.)
16
-
);
10
+
constclient=awaitPythLazerClient.create(
11
+
["wss://pyth-lazer.dourolabs.app/v1/stream"],
12
+
"access_token",
13
+
3,// Optionally specify number of parallel redundant connections to reduce the chance of dropped messages. The connections will round-robin across the provided URLs. Default is 3.
14
+
console// Optionally log socket operations (to the console in this case.)
15
+
);
17
16
18
-
client.addMessageListener((message)=>{
19
-
console.info("got message:",message);
20
-
switch(message.type){
21
-
case"json": {
22
-
if(message.value.type=="streamUpdated"){
23
-
console.info(
24
-
"stream updated for subscription",
25
-
message.value.subscriptionId,
26
-
":",
27
-
message.value.parsed?.priceFeeds
28
-
);
29
-
}
30
-
break;
17
+
// Monitor for all connections being down
18
+
client.onAllConnectionsDown().then(()=>{
19
+
// Handle complete connection failure.
20
+
// The connections will keep attempting to reconnect with expo backoff.
21
+
// To shutdown the client completely, call shutdown().
0 commit comments