forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wampy.d.ts
93 lines (79 loc) · 2.92 KB
/
wampy.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Type definitions for wampy.js v2.0.1
// Project: https://github.com/KSDaemon/wampy.js
// Definitions by: Konstantin Burkalev <https://github.com/KSDaemon>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "wampy" {
interface WampyOptions {
autoReconnect?: boolean;
reconnectInterval?: number;
maxRetries?: number;
transportEncoding?: string;
realm?: string;
helloCustomDetails?: any;
onConnect?: () => void;
onClose?: () => void;
onError?: () => void;
onReconnect?: () => void;
ws?: any;
msgpackCoder?: any;
}
interface WampyOpStatus {
code: number;
description: string;
reqId?: number;
}
interface SuccessErrorCallbacksHash {
onSuccess?: (data: any) => void;
onError?: (err: string) => void;
}
interface SubscribeCallbacksHash extends SuccessErrorCallbacksHash {
onEvent: (data: any) => void;
}
interface RegisterCallbacksHash extends SuccessErrorCallbacksHash {
rpc: (data: any) => any;
}
interface CallSuccessErrorCallbacksHash {
onSuccess: (data: any) => any;
onError?: (err: string) => void;
}
interface AdvancedOptions {
exclude?: number | number[];
eligible?: number | number[];
exclude_me?: boolean;
disclose_me?: boolean;
}
interface CallAdvancedOptions extends AdvancedOptions {
receive_progress?: boolean;
}
interface CancelAdvancedOptions {
mode?: "skip" | "kill" | "killnowait";
}
interface Wampy {
options(opts?: WampyOptions): WampyOptions | Wampy;
getOpStatus(): WampyOpStatus;
getSessionId(): number;
connect(url?: string): Wampy;
disconnect(): Wampy;
abort(): Wampy;
subscribe(topicURI: string, callbacks: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
unsubscribe(topicURI: string, callbacks?: (((data: any) => void) | SubscribeCallbacksHash)): Wampy;
publish(topicURI: string,
payload?: any,
callbacks?: SuccessErrorCallbacksHash,
advancedOptions?: AdvancedOptions): Wampy;
call(topicURI: string,
payload?: any,
callbacks?: (((data: any) => void) | CallSuccessErrorCallbacksHash),
advancedOptions?: CallAdvancedOptions): Wampy;
cancel(reqId: number,
callbacks?: ((() => void) | SuccessErrorCallbacksHash),
advancedOptions?: CancelAdvancedOptions): Wampy;
register(topicURI: string, callbacks: (((data: any) => any) | RegisterCallbacksHash)): Wampy;
unregister(topicURI: string, callbacks?: ((() => void) | SuccessErrorCallbacksHash)): Wampy;
}
interface WampyInstance {
new(url?: string, options?: WampyOptions): Wampy;
}
var wampy: WampyInstance;
export default wampy;
}