PageRenderTime 40ms CodeModel.GetById 35ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/socket.io/socket.io.d.ts

https://github.com/vilic/DefinitelyTyped
TypeScript | 78 lines | 61 code | 12 blank | 5 comment | 0 complexity | 88361e29c8e0e1ae6c5842ae29c3eeb2 MD5 | raw file
 1// Type definitions for socket.io 1.2.0
 2// Project: http://socket.io/
 3// Definitions by: PROGRE <https://github.com/progre/>
 4// Definitions: https://github.com/borisyankov/DefinitelyTyped
 5
 6///<reference path='../node/node.d.ts' />
 7
 8declare module 'socket.io' {
 9    var server: SocketIOStatic;
10
11    export = server;
12}
13
14interface SocketIOStatic {
15    (): SocketIO.Server;
16    (srv: any, opts?: any): SocketIO.Server;
17    (port: number, opts?: any): SocketIO.Server;
18    (opts: any): SocketIO.Server;
19
20    listen: SocketIOStatic;
21}
22
23declare module SocketIO {
24    interface Server {
25        serveClient(v: boolean): Server;
26        path(v: string): Server;
27        adapter(v: any): Server;
28        origins(v: string): Server;
29        sockets: Namespace;
30        attach(srv: any, opts?: any): Server;
31        attach(port: number, opts?: any): Server;
32        listen(srv: any, opts?: any): Server;
33        listen(port: number, opts?: any): Server;
34        bind(srv: any): Server;
35        onconnection(socket: any): Server;
36        of(nsp: string): Namespace;
37        emit(name: string, ...args: any[]): Socket;
38        use(fn: Function): Namespace;
39
40        on(event: 'connection', listener: (socket: Socket) => void): any;
41        on(event: 'connect', listener: (socket: Socket) => void): any;
42        on(event: string, listener: Function): any;
43    }
44
45    interface Namespace extends NodeJS.EventEmitter {
46        name: string;
47        connected: { [id: string]: Socket };
48        use(fn: Function): Namespace
49
50        on(event: 'connection', listener: (socket: Socket) => void): any;
51        on(event: 'connect', listener: (socket: Socket) => void): any;
52        on(event: string, listener: Function): any;
53    }
54
55    interface Socket {
56        rooms: string[];
57        client: Client;
58        conn: Socket;
59        request: any;
60        id: string;
61        emit(name: string, ...args: any[]): Socket;
62        join(name: string, fn?: Function): Socket;
63        leave(name: string, fn?: Function): Socket;
64        to(room: string): Socket;
65        in(room: string): Socket;
66
67        on(event: string, listener: Function): any;
68        broadcast: Socket;
69        volatile: Socket;
70        connected: boolean;
71        disconnect(close?: boolean): Socket;
72    }
73
74    interface Client {
75        conn: any;
76        request: any;
77    }
78}