UNPKG

1.36 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import http = require("http");
4
5export interface ServerOptions {
6 sockjs_url?: string | undefined;
7 prefix?: string | undefined;
8 response_limit?: number | undefined;
9 websocket?: boolean | undefined;
10 jsessionid?: any;
11 log?(severity: string, message: string): void;
12 heartbeat_delay?: number | undefined;
13 disconnect_delay?: number | undefined;
14}
15
16export function createServer(options?: ServerOptions): Server;
17
18export interface Server extends NodeJS.EventEmitter {
19 installHandlers(server: http.Server, options?: ServerOptions): any;
20
21 on(event: "connection", listener: (conn: Connection) => any): this;
22 on(event: string, listener: Function): this;
23}
24
25export interface Connection extends NodeJS.ReadWriteStream {
26 remoteAddress: string;
27 remotePort: number;
28 address: {
29 [key: string]: {
30 address: string;
31 port: number;
32 };
33 };
34 headers: {
35 [key: string]: string;
36 };
37 url: string;
38 pathname: string;
39 prefix: string;
40 protocol: string;
41 readyState: number;
42 id: string;
43
44 close(code?: string, reason?: string): boolean;
45 destroy(): void;
46
47 on(event: "data", listener: (message: string) => any): this;
48 on(event: "close", listener: () => void): this;
49 on(event: string, listener: Function): this;
50}