2
0
mirror of https://github.com/esiur/esiur-js.git synced 2025-05-06 04:22:58 +00:00

Restore fix

This commit is contained in:
Esiur Project 2022-08-30 22:30:16 +03:00
parent 1011eea4a6
commit f08df2c3fa
2 changed files with 61 additions and 9 deletions

View File

@ -1,13 +1,61 @@
#!/usr/bin/env node
console.log("Esiur Shell");
console.log("\t use: 'await wh.get(url, <attributes>);' to get a resource.");
const { spawn } = require("child_process");
const { pathToFileURL } = require("url");
let url = pathToFileURL(__dirname).href + '/../src/esiur.js';
if (process.argv.length == 2) {
console.log("Usage: <command> [arguments]");
console.log("");
console.log("Available commands:");
console.log("\tget-template\tGet a template from an IIP link.");
console.log("\tshell\tStart Node.js REPL with Esiur module loaded.");
console.log("\tversion: Print Esiur version.");
console.log("");
console.log("Global options:");
console.log("\t-u, --username\tAuthentication username");
console.log("\t-p, --password\tAuthentication password");
console.log("\t-d, --dir\tName of the directory to generate model inside.");
process.exit();
}
spawn('node', ["-i", "-e", `import('${url}');`], {
stdio: 'inherit'
});
const cmd = process.argv[2].toLowerCase();
const args = process.argv.slice(3);
if (cmd == "shell") {
console.log("Esiur Shell");
console.log("\t use: 'await wh.get(url, <attributes>);' to get a resource.");
const { spawn } = require("child_process");
const { pathToFileURL } = require("url");
let url = pathToFileURL(__dirname).href + '/../src/esiur.js';
spawn('node', ["-i", "-e", `import('${url}');`], {
stdio: 'inherit'
});
}
else if (cmd == "get-template")
{
// get username
let username = getOption(args, "--username", "-u");
let password = getOption(args, "--password", "-p");
let dir = getOption(args, "--dir", "-d");
if (args.length == 0){
console.error("No URL specified.");
process.exit();
}
let url = args[0];
console.log(`Getting ${url} ${username} ${password} ${dir}`);
}
function getOption(args, option, abbreviation) {
let index = args.indexOf(abbreviation);
if (index == -1) index = args.indexOf(option);
if (index > -1 && index + 1 < args.length)
return args.slice(index, index + 1)[1];
return null;
}

View File

@ -892,13 +892,17 @@ export default class DistributedConnection extends IStore {
if (dataType.identifier == TransmissionTypeIdentifier.ResourceList
|| dataType.identifier == TransmissionTypeIdentifier.List)
{
// remove from suspended.
this._suspendedResources.remove(r._p.instanceId);
// parse them as int
var id = data.getUint32(8);
// id changed ?
if (id != r._p.instanceId)
r._p.instanceId = id;
this._neededResources.set(id, r);
this._suspendedResources.remove(id);
await this.fetch(id, null);