Added SockJS definition

See https://github.com/sockjs/sockjs-client

Created manually by inspecting the various parameters
and return values.

There are seperate events, since, although SockJS
exposes a Websocket-like interface, it's not 100% same.
This commit is contained in:
Emil Ivanov
2012-12-26 09:28:14 +01:00
committed by Damiano
parent 07a0615ac5
commit 96fa1a3f54
+40
View File
@@ -0,0 +1,40 @@
interface SockJSSimpleEvent {
type: string;
toString(): string;
}
interface SJSOpenEvent extends SockJSSimpleEvent {}
interface SJSCloseEvent extends SockJSSimpleEvent {
code: number;
reason: string;
wasClean: bool;
}
interface SJSMessageEvent extends SockJSSimpleEvent {
data: string;
}
interface SockJS extends EventTarget {
protocol: string;
readyState: number;
onopen: (ev: SJSOpenEvent) => any;
onmessage: (ev: SJSMessageEvent) => any;
onclose: (ev: SJSCloseEvent) => any;
send(data: any): void;
close(code?: number, reason?: string): void;
OPEN: number;
CLOSING: number;
CONNECTING: number;
CLOSED: number;
}
declare var SockJS: {
prototype: SockJS;
new (url: string, options?: {
debug: bool;
devel: bool;
protocols_whitelist: string[];
}): SockJS;
}