@re-ai/inner-tool-sdk
Advanced tools
Comparing version 0.2.12 to 0.2.13
import WebSocket from "ws"; | ||
import { WSBridgeCallback, WSBridgePayload } from "../types/bridge"; | ||
export declare class WSBridgeAgent { | ||
private ws; | ||
private ws?; | ||
private callbacks; | ||
@@ -6,0 +6,0 @@ private static agents; |
@@ -19,5 +19,7 @@ "use strict"; | ||
Logger_1.Logger.warn(`[WSBridge] ${e.reason}`); | ||
this.ws = undefined; | ||
}; | ||
this.ws.onerror = (e) => { | ||
Logger_1.Logger.error(`[WSBridge] ${e.message}`); | ||
this.ws = undefined; | ||
}; | ||
@@ -31,2 +33,6 @@ if (END_TAG.split(",").length) { | ||
static setAgent(id, ws) { | ||
const agent = this.getAgent(id); | ||
if (agent) { | ||
agent.ws?.close(); | ||
} | ||
const client = new WSBridgeAgent(ws); | ||
@@ -80,3 +86,3 @@ Logger_1.Logger.info(`[WSBridge] set agent ${id}`); | ||
request(id, payload, callback) { | ||
this.ws.send(JSON.stringify({ | ||
this.ws?.send(JSON.stringify({ | ||
id, | ||
@@ -87,3 +93,3 @@ payload | ||
Logger_1.Logger.error("[WSBridge] send err", err); | ||
throw new Error(err); | ||
// throw new Error(err) | ||
} | ||
@@ -90,0 +96,0 @@ }); |
{ | ||
"name": "@re-ai/inner-tool-sdk", | ||
"version": "0.2.12", | ||
"version": "0.2.13", | ||
"description": "ReAI内部接口sdk", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -9,3 +9,3 @@ import WebSocket, { CloseEvent, ErrorEvent, MessageEvent } from "ws" | ||
private ws: WebSocket | ||
private ws?: WebSocket | ||
private callbacks: Map<string, WSBridgeCallback> | ||
@@ -26,2 +26,3 @@ | ||
Logger.warn(`[WSBridge] ${e.reason}`) | ||
this.ws = undefined | ||
} | ||
@@ -31,2 +32,3 @@ | ||
Logger.error(`[WSBridge] ${e.message}`) | ||
this.ws = undefined | ||
} | ||
@@ -42,2 +44,7 @@ | ||
static setAgent(id: string, ws: WebSocket) { | ||
const agent = this.getAgent(id) | ||
if (agent) { | ||
agent.ws?.close() | ||
} | ||
const client = new WSBridgeAgent(ws) | ||
@@ -94,3 +101,3 @@ Logger.info(`[WSBridge] set agent ${id}`) | ||
request(id: string, payload: WSBridgePayload, callback: WSBridgeCallback) { | ||
this.ws.send(JSON.stringify({ | ||
this.ws?.send(JSON.stringify({ | ||
id, | ||
@@ -101,3 +108,3 @@ payload | ||
Logger.error("[WSBridge] send err", err) | ||
throw new Error(err) | ||
// throw new Error(err) | ||
} | ||
@@ -104,0 +111,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
157573
4174