@ekhein/sekiro-node-client 2.0.3 → 2.1.0
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.
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Fork = Fork;
|
|
4
|
+
function Fork(count = 1, host, prot, clientId) {
|
|
2
5
|
return function (Client) {
|
|
3
6
|
for (let pid = 1; pid <= count; pid++) {
|
|
4
7
|
new Client(Client.name, pid, host, prot, clientId);
|
package/dist/decorators/index.js
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Action = exports.Fork = void 0;
|
|
4
|
+
var fork_decorator_1 = require("./fork.decorator");
|
|
5
|
+
Object.defineProperty(exports, "Fork", { enumerable: true, get: function () { return fork_decorator_1.Fork; } });
|
|
6
|
+
var action_decorator_1 = require("./action.decorator");
|
|
7
|
+
Object.defineProperty(exports, "Action", { enumerable: true, get: function () { return action_decorator_1.Action; } });
|
package/dist/main.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SekiroClient = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const partysocket_1 = require("partysocket");
|
|
6
|
+
const ws_1 = require("ws");
|
|
7
|
+
const result_util_1 = require("./utils/result.util");
|
|
8
|
+
const logger_util_1 = require("./utils/logger.util");
|
|
9
|
+
class SekiroClient extends partysocket_1.WebSocket {
|
|
7
10
|
scope;
|
|
8
11
|
pid;
|
|
9
12
|
host;
|
|
10
13
|
prot;
|
|
11
14
|
clientId;
|
|
12
|
-
logger = new Logger(this);
|
|
13
|
-
constructor(scope, pid, host = "192.168.2.102", prot = 5612, clientId = randomUUID().replace(/-/g, "")) {
|
|
15
|
+
logger = new logger_util_1.Logger(this);
|
|
16
|
+
constructor(scope, pid, host = "192.168.2.102", prot = 5612, clientId = (0, crypto_1.randomUUID)().replace(/-/g, "")) {
|
|
14
17
|
super("wss://", [], {
|
|
15
18
|
debug: false,
|
|
16
19
|
maxEnqueuedMessages: -1,
|
|
17
|
-
WebSocket: class extends
|
|
20
|
+
WebSocket: class extends ws_1.WebSocket {
|
|
18
21
|
constructor() {
|
|
19
22
|
const group = String(scope).toLowerCase();
|
|
20
23
|
const wsURL = new URL("/business-demo/register", "ws://" + host + ":" + prot);
|
|
@@ -51,12 +54,13 @@ export class SekiroClient extends WebSocket {
|
|
|
51
54
|
if (!handler)
|
|
52
55
|
throw new Error("No handler for this action");
|
|
53
56
|
const data = await handler.call(this, request.params);
|
|
54
|
-
const pack = Result.success(request, data);
|
|
57
|
+
const pack = result_util_1.Result.success(request, data);
|
|
55
58
|
this.send(pack);
|
|
56
59
|
}
|
|
57
60
|
catch (error) {
|
|
58
|
-
const pack = Result.unknown(request, error.message);
|
|
61
|
+
const pack = result_util_1.Result.unknown(request, error.message);
|
|
59
62
|
this.send(pack);
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
}
|
|
66
|
+
exports.SekiroClient = SekiroClient;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
class Logger {
|
|
3
6
|
context;
|
|
4
7
|
constructor(context) {
|
|
5
8
|
this.context = context;
|
|
@@ -9,7 +12,7 @@ export class Logger {
|
|
|
9
12
|
const pid = String(this.context.pid).padStart(2, "0");
|
|
10
13
|
const scope = String(this.context.scope);
|
|
11
14
|
const clientId = String(this.context.clientId);
|
|
12
|
-
const base = format("[%s] [%s] [%s] [%s] [%s]", level, time, scope, pid, clientId);
|
|
15
|
+
const base = (0, util_1.format)("[%s] [%s] [%s] [%s] [%s]", level, time, scope, pid, clientId);
|
|
13
16
|
switch (level) {
|
|
14
17
|
case "INFO":
|
|
15
18
|
console.info(base, ...message);
|
|
@@ -26,3 +29,4 @@ export class Logger {
|
|
|
26
29
|
this.log("WARN", message);
|
|
27
30
|
}
|
|
28
31
|
}
|
|
32
|
+
exports.Logger = Logger;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Result = void 0;
|
|
4
|
+
class Result {
|
|
2
5
|
static success({ __sekiro_seq__ }, data) {
|
|
3
6
|
return (JSON.stringify({ __sekiro_seq__, data, status: 0 }));
|
|
4
7
|
}
|
|
@@ -6,3 +9,4 @@ export class Result {
|
|
|
6
9
|
return (JSON.stringify({ __sekiro_seq__, message, status: -1 }));
|
|
7
10
|
}
|
|
8
11
|
}
|
|
12
|
+
exports.Result = Result;
|