oox 0.3.0-beta9 → 0.3.1
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/LICENSE +21 -21
- package/README.md +29 -32
- package/app.js +131 -143
- package/bin/argv.js +63 -70
- package/bin/cli.js +57 -43
- package/bin/configurer.js +60 -62
- package/bin/loader.mjs +392 -279
- package/bin/proxy-import.js +12 -0
- package/bin/proxy-require.js +88 -0
- package/bin/register.js +46 -55
- package/bin/starter.js +63 -66
- package/index.js +155 -168
- package/index.mjs +4 -4
- package/logger.js +25 -40
- package/modules/http/index.js +234 -192
- package/modules/http/utils.js +74 -73
- package/modules/index.js +86 -88
- package/modules/module.js +11 -16
- package/modules/socketio/client.js +97 -101
- package/modules/socketio/index.js +171 -168
- package/modules/socketio/server.js +188 -136
- package/modules/socketio/socket.js +1 -4
- package/package.json +14 -12
- package/types/app.d.ts +50 -51
- package/types/bin/argv.d.ts +8 -8
- package/types/bin/cli.d.ts +6 -2
- package/types/bin/configurer.d.ts +3 -1
- package/types/bin/proxy-import.d.ts +4 -0
- package/types/bin/proxy-require.d.ts +5 -0
- package/types/bin/register.d.ts +1 -1
- package/types/bin/starter.d.ts +5 -1
- package/types/index.d.ts +78 -76
- package/types/logger.d.ts +5 -4
- package/types/modules/http/index.d.ts +58 -47
- package/types/modules/http/utils.d.ts +14 -17
- package/types/modules/index.d.ts +24 -24
- package/types/modules/module.d.ts +11 -13
- package/types/modules/socketio/client.d.ts +23 -23
- package/types/modules/socketio/index.d.ts +37 -37
- package/types/modules/socketio/server.d.ts +44 -35
- package/types/modules/socketio/socket.d.ts +11 -11
- package/types/utils.d.ts +6 -6
- package/utils.js +57 -63
- package/bin/proxyer.js +0 -61
- package/types/bin/proxyer.d.ts +0 -1
package/types/index.d.ts
CHANGED
|
@@ -1,76 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
export
|
|
7
|
-
export declare const
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export declare function
|
|
40
|
-
export declare function
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
export declare
|
|
71
|
-
export declare function
|
|
72
|
-
export declare function
|
|
73
|
-
export declare function
|
|
74
|
-
export declare function
|
|
75
|
-
export declare function
|
|
76
|
-
export declare function
|
|
1
|
+
import * as app from './app.js';
|
|
2
|
+
import Module, { ModuleConfig } from './modules/module.js';
|
|
3
|
+
import Modules from './modules/index.js';
|
|
4
|
+
export { ReturnsBody } from './app.js';
|
|
5
|
+
export { Module, ModuleConfig };
|
|
6
|
+
export declare const modules: Modules;
|
|
7
|
+
export declare const asyncStore: import("async_hooks").AsyncLocalStorage<app.Context>, setMethods: typeof app.setMethods, getMethods: typeof app.getMethods, kvMethods: Map<string, Function>, sourceKVMethods: Map<string, Function>, call: typeof app.call, execute: typeof app.execute, logger: typeof app.logger, on: typeof app.on, once: typeof app.once, off: typeof app.off, emit: typeof app.emit;
|
|
8
|
+
export declare class Context extends app.Context {
|
|
9
|
+
sourceIP: string;
|
|
10
|
+
ip: string;
|
|
11
|
+
caller: string;
|
|
12
|
+
callerId: string;
|
|
13
|
+
connection?: RPCKeepAliveConnection;
|
|
14
|
+
toJSON?(): {} & this;
|
|
15
|
+
}
|
|
16
|
+
export declare class Config {
|
|
17
|
+
[x: string]: any;
|
|
18
|
+
name: string;
|
|
19
|
+
group: string;
|
|
20
|
+
ignore: string[];
|
|
21
|
+
entryInfo: {
|
|
22
|
+
path: string;
|
|
23
|
+
group: string;
|
|
24
|
+
};
|
|
25
|
+
host: string;
|
|
26
|
+
port: number;
|
|
27
|
+
origin: string;
|
|
28
|
+
errorStack: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare const config: Config;
|
|
31
|
+
export declare function setGenTraceIdFunction(fn: () => string): void;
|
|
32
|
+
/**
|
|
33
|
+
* 生成随机不重复id
|
|
34
|
+
*/
|
|
35
|
+
export declare function genTraceId(): string;
|
|
36
|
+
/**
|
|
37
|
+
* 获取链路跟踪上下文
|
|
38
|
+
*/
|
|
39
|
+
export declare function genContext(context?: Context): Context;
|
|
40
|
+
export declare function getContext(): Context;
|
|
41
|
+
export declare function serve(): Promise<void>;
|
|
42
|
+
export declare function stop(): Promise<void>;
|
|
43
|
+
export interface RPCConnectionAdapter {
|
|
44
|
+
rpc(connection: any, action: string, params: any[], context: Context): Promise<any>;
|
|
45
|
+
}
|
|
46
|
+
export interface RPCKeepAliveConnectionData {
|
|
47
|
+
/**
|
|
48
|
+
* 是否连接成功
|
|
49
|
+
*/
|
|
50
|
+
connected: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 连接主机地址
|
|
53
|
+
*/
|
|
54
|
+
host: string;
|
|
55
|
+
/**
|
|
56
|
+
* 连接服务名称
|
|
57
|
+
*/
|
|
58
|
+
name: string;
|
|
59
|
+
/**
|
|
60
|
+
* 目标服务网络唯一ID
|
|
61
|
+
*/
|
|
62
|
+
id: string;
|
|
63
|
+
}
|
|
64
|
+
export declare class RPCKeepAliveConnection {
|
|
65
|
+
data: RPCKeepAliveConnectionData;
|
|
66
|
+
nativeConnection: any;
|
|
67
|
+
adapter: RPCConnectionAdapter;
|
|
68
|
+
constructor(adapter: RPCConnectionAdapter, nativeConnection: any, data?: RPCKeepAliveConnectionData);
|
|
69
|
+
}
|
|
70
|
+
export declare const keepAliveConnections: Map<string, Map<string, RPCKeepAliveConnection>>;
|
|
71
|
+
export declare function getKeepAliveConnections(name: string): Map<string, RPCKeepAliveConnection>;
|
|
72
|
+
export declare function getKeepAliveConnection(name: string, id: string): RPCKeepAliveConnection | null;
|
|
73
|
+
export declare function addKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
74
|
+
export declare function removeKeepAliveConnection(connection: RPCKeepAliveConnection): void;
|
|
75
|
+
export declare function removeKeepAliveConnection(name: string, id: string): void;
|
|
76
|
+
export declare function setLoadBalancePolicy(policy: (name: string) => RPCKeepAliveConnection): void;
|
|
77
|
+
export declare function rpc(appName: string, action: string, params: any[], context?: Context): Promise<any>;
|
|
78
|
+
export declare function rpc(connection: RPCKeepAliveConnection, action: string, params: any[], context?: Context): Promise<any>;
|
package/types/logger.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export declare function info(...
|
|
2
|
-
export declare function warn(...
|
|
3
|
-
export declare function error(...
|
|
4
|
-
export declare function
|
|
1
|
+
export declare function info(...content: any[]): void;
|
|
2
|
+
export declare function warn(...content: any[]): void;
|
|
3
|
+
export declare function error(...content: any[]): void;
|
|
4
|
+
export declare function tag(name: string): void;
|
|
5
|
+
export declare function trace(name?: string): void;
|
|
@@ -1,47 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* HTTP
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
|
|
1
|
+
import * as http from 'node:http';
|
|
2
|
+
import * as oox from '../../index.js';
|
|
3
|
+
import Module, { ModuleConfig } from '../module.js';
|
|
4
|
+
export declare class HTTPConfig extends ModuleConfig {
|
|
5
|
+
port: number;
|
|
6
|
+
path: string;
|
|
7
|
+
origin: string;
|
|
8
|
+
ssl: {
|
|
9
|
+
enabled: boolean;
|
|
10
|
+
cert: string;
|
|
11
|
+
key: string;
|
|
12
|
+
ca: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export default class HTTPModule extends Module {
|
|
16
|
+
name: string;
|
|
17
|
+
config: HTTPConfig;
|
|
18
|
+
server: http.Server;
|
|
19
|
+
getUrl(): string;
|
|
20
|
+
setConfig(config: HTTPConfig): void;
|
|
21
|
+
getConfig(): HTTPConfig;
|
|
22
|
+
/**
|
|
23
|
+
* start http service
|
|
24
|
+
*/
|
|
25
|
+
serve(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* stop http service
|
|
28
|
+
*/
|
|
29
|
+
stop(): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* browser cross origin
|
|
32
|
+
*/
|
|
33
|
+
cors(request: http.IncomingMessage, response: http.ServerResponse): boolean;
|
|
34
|
+
requestHandler(request: http.IncomingMessage, response: http.ServerResponse): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* 从请求里获取调用的接口和参数
|
|
37
|
+
*/
|
|
38
|
+
getCallArgsFromRequest(request: http.IncomingMessage): Promise<any>;
|
|
39
|
+
/**
|
|
40
|
+
* HTTP-RPC服务器请求监听方法
|
|
41
|
+
*/
|
|
42
|
+
call(request: http.IncomingMessage, response: http.ServerResponse): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* HTTP Response Catch
|
|
45
|
+
*/
|
|
46
|
+
respond(_request: http.IncomingMessage, response: http.ServerResponse, returns: {
|
|
47
|
+
body?: any;
|
|
48
|
+
success: boolean;
|
|
49
|
+
error?: {
|
|
50
|
+
message: any;
|
|
51
|
+
stack?: any;
|
|
52
|
+
};
|
|
53
|
+
}): void;
|
|
54
|
+
/**
|
|
55
|
+
* HTTP RPC
|
|
56
|
+
*/
|
|
57
|
+
rpc(url: string | URL, action: string, params: Array<any>, context?: oox.Context): Promise<any>;
|
|
58
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* http request
|
|
16
|
-
*/
|
|
17
|
-
export declare function httpRequest(url: URL | string, options: http.RequestOptions, body: string): Promise<any>;
|
|
1
|
+
import * as http from 'node:http';
|
|
2
|
+
import { Readable } from 'node:stream';
|
|
3
|
+
/**
|
|
4
|
+
* Stream => Buffer
|
|
5
|
+
*/
|
|
6
|
+
export declare function stream2buffer(stream: Readable, totalLength?: number): Promise<Buffer>;
|
|
7
|
+
/**
|
|
8
|
+
* Request => JSONObject
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseHTTPBody(request: http.IncomingMessage): Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* http request
|
|
13
|
+
*/
|
|
14
|
+
export declare function httpRequest(url: URL | string, options: http.RequestOptions, body: string): Promise<any>;
|
package/types/modules/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import Module from './module';
|
|
2
|
-
import HTTP from './http';
|
|
3
|
-
import SocketIO from './socketio';
|
|
4
|
-
export default class Modules extends Module {
|
|
5
|
-
#private;
|
|
6
|
-
/**
|
|
7
|
-
* the module unique name
|
|
8
|
-
*/
|
|
9
|
-
name: string;
|
|
10
|
-
/**
|
|
11
|
-
* all builtin modules
|
|
12
|
-
*/
|
|
13
|
-
builtins: {
|
|
14
|
-
http: HTTP;
|
|
15
|
-
socketio: SocketIO;
|
|
16
|
-
};
|
|
17
|
-
constructor();
|
|
18
|
-
add(module: Module): this;
|
|
19
|
-
get(name: string): Module;
|
|
20
|
-
remove(name: string): Promise<void>;
|
|
21
|
-
setConfig(config: any): void;
|
|
22
|
-
serve(): Promise<void>;
|
|
23
|
-
stop(): Promise<void>;
|
|
24
|
-
}
|
|
1
|
+
import Module from './module.js';
|
|
2
|
+
import HTTP from './http/index.js';
|
|
3
|
+
import SocketIO from './socketio/index.js';
|
|
4
|
+
export default class Modules extends Module {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* the module unique name
|
|
8
|
+
*/
|
|
9
|
+
name: string;
|
|
10
|
+
/**
|
|
11
|
+
* all builtin modules
|
|
12
|
+
*/
|
|
13
|
+
builtins: {
|
|
14
|
+
http: HTTP;
|
|
15
|
+
socketio: SocketIO;
|
|
16
|
+
};
|
|
17
|
+
constructor();
|
|
18
|
+
add(module: Module): this;
|
|
19
|
+
get(name: string): Module;
|
|
20
|
+
remove(name: string): Promise<void>;
|
|
21
|
+
setConfig(config: any): void;
|
|
22
|
+
serve(): Promise<void>;
|
|
23
|
+
stop(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export declare class ModuleConfig {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
config:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
stop(): Promise<void>;
|
|
13
|
-
}
|
|
1
|
+
export declare class ModuleConfig {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
}
|
|
4
|
+
export default class Module {
|
|
5
|
+
config: ModuleConfig;
|
|
6
|
+
name: string;
|
|
7
|
+
setConfig(config: any): void;
|
|
8
|
+
getConfig(): ModuleConfig;
|
|
9
|
+
serve(): Promise<void>;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { ClientSocket as Socket } from './socket';
|
|
2
|
-
import SocketIOServer from './server';
|
|
3
|
-
export default class SocketIOCore extends SocketIOServer {
|
|
4
|
-
/**
|
|
5
|
-
* connect to <SocketIO RPC> service
|
|
6
|
-
*/
|
|
7
|
-
connect(url: string): Promise<Socket>;
|
|
8
|
-
/**
|
|
9
|
-
* 客户端Socket连接事件
|
|
10
|
-
*/
|
|
11
|
-
clientOnSocketConnection(socket: Socket): void;
|
|
12
|
-
clientOnDisconnect(socket: Socket, reason: any): void;
|
|
13
|
-
clientOnConnection(socket: Socket): void;
|
|
14
|
-
/**
|
|
15
|
-
* 客户端Socket断开事件
|
|
16
|
-
* @param {Socket} socket
|
|
17
|
-
*/
|
|
18
|
-
clientOnSocketDisconnect(socket: Socket, reason: any): void;
|
|
19
|
-
/**
|
|
20
|
-
* 等待socket连接
|
|
21
|
-
*/
|
|
22
|
-
clientWaitConnection(socket: Socket): Promise<void>;
|
|
23
|
-
}
|
|
1
|
+
import { ClientSocket as Socket } from './socket.js';
|
|
2
|
+
import SocketIOServer from './server.js';
|
|
3
|
+
export default class SocketIOCore extends SocketIOServer {
|
|
4
|
+
/**
|
|
5
|
+
* connect to <SocketIO RPC> service
|
|
6
|
+
*/
|
|
7
|
+
connect(url: string): Promise<Socket>;
|
|
8
|
+
/**
|
|
9
|
+
* 客户端Socket连接事件
|
|
10
|
+
*/
|
|
11
|
+
clientOnSocketConnection(socket: Socket): void;
|
|
12
|
+
clientOnDisconnect(socket: Socket, reason: any): void;
|
|
13
|
+
clientOnConnection(socket: Socket): void;
|
|
14
|
+
/**
|
|
15
|
+
* 客户端Socket断开事件
|
|
16
|
+
* @param {Socket} socket
|
|
17
|
+
*/
|
|
18
|
+
clientOnSocketDisconnect(socket: Socket, reason: any): void;
|
|
19
|
+
/**
|
|
20
|
+
* 等待socket连接
|
|
21
|
+
*/
|
|
22
|
+
clientWaitConnection(socket: Socket): Promise<void>;
|
|
23
|
+
}
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import SocketIOClient from './client';
|
|
2
|
-
import * as oox from '../../index';
|
|
3
|
-
import { RPCKeepAliveConnectionData, RPCConnectionAdapter } from '../../index';
|
|
4
|
-
import { Socket, sockets, ServerSocket, ClientSocket } from './socket';
|
|
5
|
-
export { Socket, sockets };
|
|
6
|
-
export default class SocketIOModule extends SocketIOClient implements RPCConnectionAdapter {
|
|
7
|
-
sockets: Map<string, Socket>;
|
|
8
|
-
serve(): Promise<void>;
|
|
9
|
-
onSyncConnection(socket: Socket): oox.RPCKeepAliveConnectionData[];
|
|
10
|
-
serverOnDisconnect(socket: ServerSocket, reason: string): void;
|
|
11
|
-
clientOnDisconnect(socket: ClientSocket, reason: any): void;
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @param socket 是由哪个通道发送过来的
|
|
15
|
-
* @param connectionDatas
|
|
16
|
-
*/
|
|
17
|
-
clientOnSyncConnection(socket: Socket, connectionDatas: RPCKeepAliveConnectionData[]): void;
|
|
18
|
-
onFetchActions(socket: Socket, search: string): string[];
|
|
19
|
-
fetchActions(url: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
20
|
-
fetchActions(name: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
21
|
-
onConnection(socket: Socket): void;
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
* @param {Socket} socket
|
|
25
|
-
*/
|
|
26
|
-
serverOnConnection(socket: ServerSocket): void;
|
|
27
|
-
call(action: string, params: any[], context: oox.Context, callback?: (returns: any) => void): Promise<oox.ReturnsBody>;
|
|
28
|
-
clientOnConnection(socket: ClientSocket): void;
|
|
29
|
-
/**
|
|
30
|
-
* socketio emit
|
|
31
|
-
*/
|
|
32
|
-
emit(url: string,
|
|
33
|
-
/**
|
|
34
|
-
* RPC
|
|
35
|
-
*/
|
|
36
|
-
rpc(url: string, action: string, params: [], context?: oox.Context): Promise<any>;
|
|
37
|
-
}
|
|
1
|
+
import SocketIOClient from './client.js';
|
|
2
|
+
import * as oox from '../../index.js';
|
|
3
|
+
import { RPCKeepAliveConnectionData, RPCConnectionAdapter } from '../../index.js';
|
|
4
|
+
import { Socket, sockets, ServerSocket, ClientSocket } from './socket.js';
|
|
5
|
+
export { Socket, sockets };
|
|
6
|
+
export default class SocketIOModule extends SocketIOClient implements RPCConnectionAdapter {
|
|
7
|
+
sockets: Map<string, Socket>;
|
|
8
|
+
serve(): Promise<void>;
|
|
9
|
+
onSyncConnection(socket: Socket): oox.RPCKeepAliveConnectionData[];
|
|
10
|
+
serverOnDisconnect(socket: ServerSocket, reason: string): void;
|
|
11
|
+
clientOnDisconnect(socket: ClientSocket, reason: any): void;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param socket 是由哪个通道发送过来的
|
|
15
|
+
* @param connectionDatas
|
|
16
|
+
*/
|
|
17
|
+
clientOnSyncConnection(socket: Socket, connectionDatas: RPCKeepAliveConnectionData[]): void;
|
|
18
|
+
onFetchActions(socket: Socket, search: string): string[];
|
|
19
|
+
fetchActions(url: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
20
|
+
fetchActions(name: string, search?: string): Promise<RPCKeepAliveConnectionData[]>;
|
|
21
|
+
onConnection(socket: Socket): void;
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Socket} socket
|
|
25
|
+
*/
|
|
26
|
+
serverOnConnection(socket: ServerSocket): void;
|
|
27
|
+
call(action: string, params: any[], context: oox.Context, callback?: (returns: any) => void): Promise<oox.ReturnsBody>;
|
|
28
|
+
clientOnConnection(socket: ClientSocket): void;
|
|
29
|
+
/**
|
|
30
|
+
* socketio emit
|
|
31
|
+
*/
|
|
32
|
+
emit(url: string, event: string, params: any[]): Promise<unknown>;
|
|
33
|
+
/**
|
|
34
|
+
* RPC
|
|
35
|
+
*/
|
|
36
|
+
rpc(url: string, action: string, params: [], context?: oox.Context): Promise<any>;
|
|
37
|
+
}
|
|
@@ -1,35 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
import * as
|
|
3
|
-
import { Server, ServerOptions } from 'socket.io';
|
|
4
|
-
import { Module, ModuleConfig } from '../../index';
|
|
5
|
-
import { ServerSocket as Socket } from './socket';
|
|
6
|
-
export declare class SocketIOConfig extends ModuleConfig {
|
|
7
|
-
port: number;
|
|
8
|
-
path: string;
|
|
9
|
-
origin: string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
import * as http from 'node:http';
|
|
2
|
+
import * as https from 'node:https';
|
|
3
|
+
import { Server, ServerOptions } from 'socket.io';
|
|
4
|
+
import { Module, ModuleConfig } from '../../index.js';
|
|
5
|
+
import { ServerSocket as Socket } from './socket.js';
|
|
6
|
+
export declare class SocketIOConfig extends ModuleConfig {
|
|
7
|
+
port: number;
|
|
8
|
+
path: string;
|
|
9
|
+
origin: string;
|
|
10
|
+
ssl: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
cert: string;
|
|
13
|
+
key: string;
|
|
14
|
+
ca: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export default class SocketIOServer extends Module {
|
|
18
|
+
#private;
|
|
19
|
+
name: string;
|
|
20
|
+
config: SocketIOConfig;
|
|
21
|
+
server: http.Server | https.Server;
|
|
22
|
+
socketServer: Server;
|
|
23
|
+
static isWebSocketUrl(url: string): boolean;
|
|
24
|
+
static genWebSocketUrl(url: string): string;
|
|
25
|
+
getUrl(): string;
|
|
26
|
+
setConfig(config: SocketIOConfig): void;
|
|
27
|
+
getConfig(): SocketIOConfig;
|
|
28
|
+
serve(): Promise<void>;
|
|
29
|
+
stop(): Promise<void>;
|
|
30
|
+
genSocketIOServerOptions(): Partial<ServerOptions>;
|
|
31
|
+
createSocketIOServer(): void;
|
|
32
|
+
/**
|
|
33
|
+
* 服务端Socket连接事件
|
|
34
|
+
*/
|
|
35
|
+
serverOnSocketConnection(socket: Socket): void;
|
|
36
|
+
serverOnConnection(socket: Socket): void;
|
|
37
|
+
/**
|
|
38
|
+
* 服务端Socket断开事件
|
|
39
|
+
* @param {Socket} socket
|
|
40
|
+
* @param {Error} reason
|
|
41
|
+
*/
|
|
42
|
+
serverOnSocketDisconnect(socket: Socket, reason: string): void;
|
|
43
|
+
serverOnDisconnect(socket: Socket, reason: string): void;
|
|
44
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Socket as _ServerSocket } from 'socket.io';
|
|
2
|
-
import { Socket as _ClientSocket } from 'socket.io-client';
|
|
3
|
-
import { RPCKeepAliveConnectionData } from '../../index';
|
|
4
|
-
export interface ServerSocket extends _ServerSocket {
|
|
5
|
-
data: RPCKeepAliveConnectionData;
|
|
6
|
-
}
|
|
7
|
-
export interface ClientSocket extends _ClientSocket {
|
|
8
|
-
data: RPCKeepAliveConnectionData;
|
|
9
|
-
}
|
|
10
|
-
export
|
|
11
|
-
export declare const sockets: Map<string, Socket>;
|
|
1
|
+
import { Socket as _ServerSocket } from 'socket.io';
|
|
2
|
+
import { Socket as _ClientSocket } from 'socket.io-client';
|
|
3
|
+
import { RPCKeepAliveConnectionData } from '../../index.js';
|
|
4
|
+
export interface ServerSocket extends _ServerSocket {
|
|
5
|
+
data: RPCKeepAliveConnectionData;
|
|
6
|
+
}
|
|
7
|
+
export interface ClientSocket extends _ClientSocket {
|
|
8
|
+
data: RPCKeepAliveConnectionData;
|
|
9
|
+
}
|
|
10
|
+
export type Socket = ServerSocket | ClientSocket;
|
|
11
|
+
export declare const sockets: Map<string, Socket>;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function getIPAddress(version?: number): string[];
|
|
2
|
-
export declare function getAllCallablePropertyNames(obj: any): string[];
|
|
3
|
-
export declare function genKVMethods(methods: any, kvMethods?: Map<string, Function>, sourceKVMethods?: Map<string, Function>, nameStack?: string[]): {
|
|
4
|
-
kvMethods: Map<string, Function>;
|
|
5
|
-
sourceKVMethods: Map<string, Function>;
|
|
6
|
-
};
|
|
1
|
+
export declare function getIPAddress(version?: number): string[];
|
|
2
|
+
export declare function getAllCallablePropertyNames(obj: any): string[];
|
|
3
|
+
export declare function genKVMethods(methods: any, kvMethods?: Map<string, Function>, sourceKVMethods?: Map<string, Function>, nameStack?: string[]): {
|
|
4
|
+
kvMethods: Map<string, Function>;
|
|
5
|
+
sourceKVMethods: Map<string, Function>;
|
|
6
|
+
};
|