forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autobahn.d.ts
195 lines (152 loc) · 5.12 KB
/
autobahn.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// Type definitions for AutobahnJS v0.9.6
// Project: http://autobahn.ws/js/
// Definitions by: Elad Zelingher <https://github.com/darkl/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../when/when.d.ts" />
declare module autobahn {
export class Session {
id: number;
realm: string;
isOpen: boolean;
features: any;
caller_disclose_me: boolean;
publisher_disclose_me: boolean;
subscriptions: ISubscription[][];
registrations: IRegistration[];
constructor(transport: ITransport, defer: DeferFactory, challenge: OnChallengeHandler);
join(realm: string, authmethods: string[], authid: string): void;
leave(reason: string, message: string): void;
call<TResult>(procedure: string, args?: any[], kwargs?: any, options?: ICallOptions): When.Promise<TResult>;
publish(topic: string, args?: any[], kwargs?: any, options?: IPublishOptions): When.Promise<IPublication>;
subscribe(topic: string, handler: SubscribeHandler, options?: ISubscribeOptions): When.Promise<ISubscription>;
register(procedure: string, endpoint: RegisterEndpoint, options?: IRegisterOptions): When.Promise<IRegistration>;
unsubscribe(subscription: ISubscription): When.Promise<any>;
unregister(registration: IRegistration): When.Promise<any>;
prefix(prefix: string, uri: string): void;
resolve(curie: string): string;
onjoin: (roleFeatures: any) => void;
onleave: (reason: string, details: any) => void;
}
interface IInvocation {
caller?: number;
progress?: boolean;
procedure: string;
}
interface IEvent {
publication: number;
publisher?: number;
topic: string;
}
interface IResult {
args: any[];
kwargs: any;
}
interface IError {
error: string;
args: any[];
kwargs: any;
}
type SubscribeHandler = (args?: any[], kwargs?: any, details?: IEvent) => void;
interface ISubscription {
topic: string;
handler: SubscribeHandler;
options: ISubscribeOptions;
session: Session;
id: number;
active: boolean;
unsubscribe(): When.Promise<any>;
}
type RegisterEndpoint = (args?: any[], kwargs?: any, details?: IInvocation) => void;
interface IRegistration {
procedure: string;
endpoint: RegisterEndpoint;
options: IRegisterOptions;
session: Session;
id: number;
active: boolean;
unregister(): When.Promise<any>;
}
interface IPublication {
id: number;
}
interface ICallOptions {
timeout?: number;
receive_progress?: boolean;
disclose_me?: boolean;
}
interface IPublishOptions {
exclude?: number[];
eligible?: number[];
disclose_me? : Boolean;
}
interface ISubscribeOptions {
match? : string;
}
interface IRegisterOptions {
disclose_caller?: boolean;
}
export class Connection {
constructor(options?: IConnectionOptions);
open(): void;
close(reason: string, message: string): void;
onopen: (session: Session, details: any) => void;
onclose: (reason: string, details: any) => boolean;
}
interface ITransportDefinition {
url?: string;
protocols?: string[];
type: string;
}
type DeferFactory = () => any;
type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise<string>;
interface IConnectionOptions {
use_es6_promises?: boolean;
// use explicit deferred factory, e.g. jQuery.Deferred or Q.defer
use_deferred?: DeferFactory;
transports?: ITransportDefinition[];
retry_if_unreachable?: boolean;
max_retries?: number;
initial_retry_delay?: number;
max_retry_delay?: number;
retry_delay_growth?: number;
retry_delay_jitter?: number;
url?: string;
protocols?: string[];
onchallenge?: (session: Session, method: string, extra: any) => OnChallengeHandler;
realm?: string;
authmethods?: string[];
authid?: string;
}
interface ICloseEventDetails {
wasClean: boolean;
reason: string;
code: number;
}
interface ITransport {
onopen: () => void;
onmessage: (message: any[]) => void;
onclose: (details: ICloseEventDetails) => void;
send(message: any[]): void;
close(errorCode: number, reason?: string): void;
}
interface ITransportFactory {
//constructor(options: any);
type: string;
create(): ITransport;
}
interface ITransports {
register(name: string, factory: any): void;
isRegistered(name: string): boolean;
get(name: string): any;
list(): any[];
}
interface ILog {
debug(...args: any[]): void;
}
interface IUtil {
assert(condition: boolean, message: string): void;
}
var util: IUtil;
var log: ILog;
var transports: ITransports;
}