forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
signalr.d.ts
113 lines (93 loc) · 3.41 KB
/
signalr.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
// Type definitions for SignalR 1.0
// Project: http://www.asp.net/signalr
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, T. Michael Keesey <https://github.com/keesey/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface HubMethod {
(callback: (data: string) => void ): any;
}
interface SignalREvents {
onStart: string;
onStarting: string;
onReceived: string;
onError: string;
onConnectionSlow: string;
onReconnect: string;
onStateChanged: string;
onDisconnect: string;
}
interface SignalRStateChange {
oldState: number;
newState: number;
}
interface SignalR {
events: SignalREvents;
connectionState: any;
transports: any;
hub: HubConnection;
id: string;
logging: boolean;
messageId: string;
url: string;
qs: any;
state: number;
(url: string, queryString?: any, logging?: boolean): SignalR;
hubConnection(url?: string): SignalR;
log(msg: string, logging: boolean): void;
isCrossDomain(url: string): boolean;
changeState(connection: SignalR, expectedState: number, newState: number): boolean;
isDisconnecting(connection: SignalR): boolean;
// createHubProxy(hubName: string): SignalR;
start(): JQueryPromise<any>;
start(callback: () => void ): JQueryPromise<any>;
start(settings: ConnectionSettings): JQueryPromise<any>;
start(settings: ConnectionSettings, callback: () => void ): JQueryPromise<any>;
send(data: string): void;
stop(async?: boolean, notifyServer?: boolean): void;
starting(handler: () => void ): SignalR;
received(handler: (data: any) => void ): SignalR;
error(handler: (error: Error) => void ): SignalR;
stateChanged(handler: (change: SignalRStateChange) => void ): SignalR;
disconnected(handler: () => void ): SignalR;
connectionSlow(handler: () => void ): SignalR;
sending(handler: () => void ): SignalR;
reconnecting(handler: () => void): SignalR;
reconnected(handler: () => void): SignalR;
}
interface HubProxy {
(connection: HubConnection, hubName: string): HubProxy;
state: any;
connection: HubConnection;
hubName: string;
init(connection: HubConnection, hubName: string): void;
hasSubscriptions(): boolean;
on(eventName: string, callback: (...msg: any[]) => void ): HubProxy;
off(eventName: string, callback: (msg: any) => void ): HubProxy;
invoke(methodName: string, ...args: any[]): JQueryDeferred<any>;
}
interface HubConnectionSettings {
queryString?: string;
logging?: boolean;
useDefaultPath?: boolean;
}
interface HubConnection extends SignalR {
//(url?: string, queryString?: any, logging?: boolean): HubConnection;
proxies: any;
transport: { name: string, supportsKeepAlive: () => boolean };
received(callback: (data: { Id: any; Method: any; Hub: any; State: any; Args: any; }) => void ): HubConnection;
createHubProxy(hubName: string): HubProxy;
}
interface SignalRfn {
init(url: any, qs: any, logging: any): any;
}
interface ConnectionSettings {
transport?: any;
callback?: any;
waitForPageLoad?: boolean;
jsonp?: boolean;
}
interface JQueryStatic {
signalR: SignalR;
connection: SignalR;
hubConnection(url?: string, options?: HubConnectionSettings): HubConnection;
}