Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@oada/client

Package Overview
Dependencies
Maintainers
8
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@oada/client - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0-alpha

1

dist/client.d.ts

@@ -9,2 +9,3 @@ import { WebSocketClient } from "./websocket";

_ws?: WebSocketClient;
pingInterval?: number;
}

@@ -11,0 +12,0 @@ export declare type Response = SocketResponse;

2

dist/client.js

@@ -24,3 +24,3 @@ "use strict";

this._concurrency = config.concurrency || this._concurrency;
this._ws = new websocket_1.WebSocketClient(this._domain, this._concurrency);
this._ws = new websocket_1.WebSocketClient(this._domain, this._concurrency, config.pingInterval);
}

@@ -27,0 +27,0 @@ clone(token) {

@@ -5,3 +5,3 @@ import { Json, Change } from ".";

path: string;
method: "head" | "get" | "put" | "post" | "delete" | "watch" | "unwatch";
method: "head" | "get" | "put" | "post" | "delete" | "watch" | "unwatch" | "ping";
headers: Record<string, string>;

@@ -29,3 +29,10 @@ data?: Json;

private _q;
constructor(domain: string, concurrency?: number);
private _pingInterval;
private _timeoutTimerID;
private _pingTimerID;
constructor(domain: string, concurrency?: number, pingInterval?: number);
private _sendPing;
private _resetReconnectTimers;
private _reconnect;
private _connect;
disconnect(): Promise<void>;

@@ -32,0 +39,0 @@ isConnected(): boolean;

@@ -34,7 +34,36 @@ "use strict";

class WebSocketClient {
constructor(domain, concurrency = 10) {
constructor(domain, concurrency = 10, pingInterval = 60000) {
this._domain = domain;
this._requests = new Map();
this._q = new p_queue_1.default({ concurrency });
this._q.on("active", () => {
trace(`WS Queue. Size: ${this._q.size} pending: ${this._q.pending}`);
});
this._status = ConnectionStatus.Connecting;
this._ws = new Promise((resolve) => {
this._ws = this._connect();
this._pingInterval = pingInterval;
this._pingTimerID = setTimeout(this._sendPing.bind(this), this._pingInterval);
this._timeoutTimerID = setTimeout(this._reconnect.bind(this), this._pingInterval + 5000);
}
_sendPing() {
const pingRequest = {
method: "ping",
headers: { authorization: "" },
path: "",
};
this.request(pingRequest);
}
_resetReconnectTimers() {
clearTimeout(this._timeoutTimerID);
clearTimeout(this._pingTimerID);
this._pingTimerID = setTimeout(this._sendPing.bind(this), this._pingInterval);
this._timeoutTimerID = setTimeout(this._reconnect.bind(this), this._pingInterval + 5000);
}
_reconnect() {
this._ws = this._connect();
this._resetReconnectTimers();
}
_connect() {
this._status = ConnectionStatus.Connecting;
return new Promise((resolve) => {
const ws = new WebSocket("wss://" + this._domain, {

@@ -52,6 +81,2 @@ origin: "https://" + this._domain,

});
this._q = new p_queue_1.default({ concurrency });
this._q.on("active", () => {
trace(`WS Queue. Size: ${this._q.size} pending: ${this._q.pending}`);
});
}

@@ -102,2 +127,3 @@ async disconnect() {

_receive(m) {
this._resetReconnectTimers();
try {

@@ -104,0 +130,0 @@ const msg = JSON.parse(m.data.toString());

{
"name": "@oada/client",
"version": "1.1.0",
"version": "1.2.0-alpha",
"description": "A lightweight client tool to interact with an OADA-compliant server",

@@ -20,3 +20,3 @@ "main": "dist/index.js",

"dependencies": {
"@oada/types": "^1.0.6",
"@oada/types": "^1.2.0-beta.5",
"debug": "^4.1.1",

@@ -23,0 +23,0 @@ "isomorphic-ws": "^4.0.1",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc