forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sockjs-client.d.ts
65 lines (54 loc) · 1.54 KB
/
sockjs-client.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
// Type definitions for sockjs-client 1.0.3
// Project: https://github.com/sockjs/sockjs-client
// Definitions by: Emil Ivanov <https://github.com/vladev>, Alexander Rusakov <https://github.com/arusakov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare namespace __SockJSClient {
interface BaseEvent {
type: string;
}
interface OpenEvent extends BaseEvent {}
interface CloseEvent extends BaseEvent {
code: number;
reason: string;
wasClean: boolean;
}
interface MessageEvent extends BaseEvent {
data: string;
}
interface SessionGenerator {
(): string;
}
interface Options {
server?: string;
sessionId?: number | SessionGenerator;
transports?: string | string[]
}
enum State {
CONNECTING = 0, OPEN, CLOSING, CLOSED
}
interface SockJSClass extends EventTarget {
readyState: State;
protocol: string;
url: string;
onopen: (e: OpenEvent) => any;
onclose: (e: CloseEvent) => any;
onmessage: (e: MessageEvent) => any;
send(data: any): void;
close(code?: number, reason?: string): void;
}
}
declare module 'sockjs-client' {
import SockJSClass = __SockJSClient.SockJSClass;
import Options = __SockJSClient.Options;
import State = __SockJSClient.State;
var SockJS: {
new(url: string, _reserved?: any, options?: Options): SockJSClass;
(url: string, _reserved?: any, options?: Options): SockJSClass;
prototype: SockJSClass;
CONNECTING: State;
OPEN: State;
CLOSING: State;
CLOSED: State;
};
export = SockJS;
}