hypha-rpc 0.1.7 → 0.1.10
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/dist/hypha-rpc-websocket.js +12 -15
- package/dist/hypha-rpc-websocket.js.map +1 -1
- package/dist/hypha-rpc-websocket.min.js +1 -1
- package/dist/hypha-rpc-websocket.min.js.map +1 -1
- package/index.js +1 -1
- package/package.json +1 -1
- package/src/rpc.js +1 -1
- package/src/websocket-client.js +11 -14
|
@@ -483,7 +483,7 @@ class RPC extends _utils_js__WEBPACK_IMPORTED_MODULE_0__.MessageEmitter {
|
|
|
483
483
|
svc.id = `${provider}:${service_id}`;
|
|
484
484
|
return svc;
|
|
485
485
|
} catch (e) {
|
|
486
|
-
console.
|
|
486
|
+
console.warn("Failed to get remote service: " + service_uri, e);
|
|
487
487
|
throw e;
|
|
488
488
|
}
|
|
489
489
|
}
|
|
@@ -4306,13 +4306,13 @@ class WebsocketRPCConnection {
|
|
|
4306
4306
|
}
|
|
4307
4307
|
resolve(this.connection_info);
|
|
4308
4308
|
} else if (first_message.type == "error") {
|
|
4309
|
-
const error =
|
|
4309
|
+
const error = "ConnectionAbortedError: " + first_message.message;
|
|
4310
4310
|
console.error("Failed to connect, " + error);
|
|
4311
4311
|
reject(new Error(error));
|
|
4312
4312
|
return;
|
|
4313
4313
|
} else {
|
|
4314
|
-
console.error("Unexpected message received from the server:", data);
|
|
4315
|
-
reject(new Error("Unexpected message received from the server"));
|
|
4314
|
+
console.error("ConnectionAbortedError: Unexpected message received from the server:", data);
|
|
4315
|
+
reject(new Error("ConnectionAbortedError: Unexpected message received from the server"));
|
|
4316
4316
|
return;
|
|
4317
4317
|
}
|
|
4318
4318
|
};
|
|
@@ -4374,11 +4374,9 @@ class WebsocketRPCConnection {
|
|
|
4374
4374
|
this._websocket &&
|
|
4375
4375
|
this._websocket.readyState === WebSocket.CLOSED
|
|
4376
4376
|
) {
|
|
4377
|
-
if ([1000].includes(event.code)) {
|
|
4377
|
+
if ([1000, 1001].includes(event.code)) {
|
|
4378
4378
|
console.info(
|
|
4379
|
-
|
|
4380
|
-
event.code,
|
|
4381
|
-
event.reason,
|
|
4379
|
+
`Websocket connection closed (code: ${event.code}): ${event.reason}`
|
|
4382
4380
|
);
|
|
4383
4381
|
if (this._handle_disconnected) {
|
|
4384
4382
|
this._handle_disconnected(event.reason);
|
|
@@ -4478,6 +4476,7 @@ async function login(config) {
|
|
|
4478
4476
|
});
|
|
4479
4477
|
try {
|
|
4480
4478
|
const svc = await server.get_service(service_id);
|
|
4479
|
+
(0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.assert)(svc, `Failed to get the login service: ${service_id}`);
|
|
4481
4480
|
const context = await svc.start();
|
|
4482
4481
|
if (callback) {
|
|
4483
4482
|
await callback(context);
|
|
@@ -4548,17 +4547,13 @@ async function connectToServer(config) {
|
|
|
4548
4547
|
return await wm.get_service(query + ":default");
|
|
4549
4548
|
}
|
|
4550
4549
|
|
|
4551
|
-
async function disconnect() {
|
|
4552
|
-
await rpc.disconnect();
|
|
4553
|
-
await connection.disconnect();
|
|
4554
|
-
}
|
|
4555
4550
|
if (connection_info) {
|
|
4556
4551
|
wm.config = Object.assign(wm.config, connection_info);
|
|
4557
4552
|
}
|
|
4558
4553
|
wm.export = _export;
|
|
4559
4554
|
wm.getPlugin = getPlugin;
|
|
4560
4555
|
wm.listPlugins = wm.listServices;
|
|
4561
|
-
wm.disconnect = disconnect;
|
|
4556
|
+
wm.disconnect = rpc.disconnect.bind(rpc);
|
|
4562
4557
|
wm.registerCodec = rpc.register_codec.bind(rpc);
|
|
4563
4558
|
wm.emit = rpc.emit;
|
|
4564
4559
|
wm.on = rpc.on;
|
|
@@ -4566,7 +4561,7 @@ async function connectToServer(config) {
|
|
|
4566
4561
|
rpc.on("force-exit", async (message) => {
|
|
4567
4562
|
if (message.from === "*/" + connection.manager_id) {
|
|
4568
4563
|
console.log("Disconnecting from server, reason:", message.reason);
|
|
4569
|
-
await disconnect();
|
|
4564
|
+
await rpc.disconnect();
|
|
4570
4565
|
}
|
|
4571
4566
|
});
|
|
4572
4567
|
}
|
|
@@ -4580,7 +4575,9 @@ async function connectToServer(config) {
|
|
|
4580
4575
|
[undefined, true, false, "auto"].includes(webrtc),
|
|
4581
4576
|
"webrtc must be true, false or 'auto'",
|
|
4582
4577
|
);
|
|
4583
|
-
|
|
4578
|
+
// pass other arguments to get_service
|
|
4579
|
+
const otherArgs = Array.prototype.slice.call(arguments, 3);
|
|
4580
|
+
const svc = await _get_service(query, ...otherArgs);
|
|
4584
4581
|
if (webrtc === true || webrtc === "auto") {
|
|
4585
4582
|
if (svc.id.includes(":") && svc.id.includes("/")) {
|
|
4586
4583
|
const client = svc.id.split(":")[0];
|