forked from alex8088/node-signalr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
74 lines (57 loc) · 1.62 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
declare enum ConnectionState {
Connected = 1,
Reconnecting = 2,
Disconnected = 4,
}
type ErrorMessages = {
invalidURL: 'Invalid URL',
invalidProtocol: 'Invalid protocol',
noHub: 'No hub',
unsupportedWebsocket: 'Websockets is not supported',
unauthorized: 'Unauthorized',
connectLost: 'Connect lost',
negotiateError: 'Negotiate error',
startError: 'Start error',
connectError: 'Connect error',
socketError: 'Socket error',
abortError: 'Abort error'
};
type Connection = {
state: ConnectionState,
hub: hub,
lastMessageAt: number
}
interface Headers {
[key: string]: string
}
interface Qs {
[key: string]: string
}
export declare class client {
url: string
qs: Qs
headers: Headers
reconnectDelayTime: number
requestTimeout: number
callTimeout: number
connection: Connection
constructor(url: string, hubs: string[])
on(event: 'connected', listener: (name: string) => void): this
on(event: 'reconnecting', listener: (count: number) => void): this
on(event: 'disconnected', listener: (reason: string) => void): this
on(event: 'error', listener: (code: string, ex?: any) => void): this
start()
end()
}
export declare class hub {
call(hubName: string, methodName: string, ...args: string[])
on(event: string, hubName: string, listener: (message: string) => void): hub
invoke(hubName: string, methodName: string, message: string)
constructor(client: client)
}
export declare const error: ErrorMessages
export declare const connectionState: {
connected: 1,
reconnecting: 2,
disconnected: 4
}