-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
54 lines (42 loc) · 1.42 KB
/
index.d.ts
1
2
3
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
45
46
47
48
49
50
51
52
53
54
/// <reference types="@types/zen-observable" />
/// <reference types="@slimio/safe-emitter" />
import * as SafeEmitter from "@slimio/safe-emitter";
import * as Net from "net";
declare namespace TcpClient {
interface ConstructorOptions {
host?: string;
port?: number;
}
interface AgentInfo {
location: string;
version: string;
}
type Calback = { [key: string]: any };
// TODO how to compose from Addon ? (instead of creating a whole thing here...)
interface Targets {
"gate.get_info": null;
"gate.start": null;
"gate.stop": null;
"gate.health_check": null;
}
interface Events {
connect: void;
}
}
declare class TcpClient<T extends TcpClient.Calback = TcpClient.Targets> extends SafeEmitter<TcpClient.Events> {
constructor(options?: TcpClient.ConstructorOptions);
public readonly agent: TcpClient.AgentInfo | null;
public static DEFAULT_PORT: number;
public client: Net.Socket;
public host: string;
public port: string;
getActiveAddons(): Promise<String[]>;
ping(): Promise<void>;
connect(): Promise<void>;
// TODO: how to handle the return type on T ?
sendMessage<K extends keyof T>(target: K, args?: T[K]): ZenObservable.ObservableLike<any>;
sendOne<K extends keyof T>(target: K, args?: T[K]): Promise<any>;
close(): void;
}
export as namespace TcpClient;
export = TcpClient;