forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
socket.io.d.ts
78 lines (66 loc) · 2.27 KB
/
socket.io.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
// Type definitions for socket.io 1.2.0
// Project: http://socket.io/
// Definitions by: PROGRE <https://github.com/progre/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///<reference path='../node/node.d.ts' />
declare module 'socket.io' {
var server: SocketIOStatic;
export = server;
}
interface SocketIOStatic {
(): SocketIO.Server;
(srv: any, opts?: any): SocketIO.Server;
(port: number, opts?: any): SocketIO.Server;
(opts: any): SocketIO.Server;
listen: SocketIOStatic;
}
declare module SocketIO {
interface Server {
serveClient(v: boolean): Server;
path(v: string): Server;
adapter(v: any): Server;
origins(v: string): Server;
sockets: Namespace;
attach(srv: any, opts?: any): Server;
attach(port: number, opts?: any): Server;
listen(srv: any, opts?: any): Server;
listen(port: number, opts?: any): Server;
bind(srv: any): Server;
onconnection(socket: any): Server;
of(nsp: string): Namespace;
emit(name: string, ...args: any[]): Socket;
use(fn: Function): Namespace;
on(event: 'connection', listener: (socket: Socket) => void): any;
on(event: 'connect', listener: (socket: Socket) => void): any;
on(event: string, listener: Function): any;
}
interface Namespace extends NodeJS.EventEmitter {
name: string;
connected: { [id: string]: Socket };
use(fn: Function): Namespace
on(event: 'connection', listener: (socket: Socket) => void): any;
on(event: 'connect', listener: (socket: Socket) => void): any;
on(event: string, listener: Function): any;
}
interface Socket {
rooms: string[];
client: Client;
conn: Socket;
request: any;
id: string;
emit(name: string, ...args: any[]): Socket;
join(name: string, fn?: Function): Socket;
leave(name: string, fn?: Function): Socket;
to(room: string): Socket;
in(room: string): Socket;
on(event: string, listener: Function): any;
broadcast: Socket;
volatile: Socket;
connected: boolean;
disconnect(close?: boolean): Socket;
}
interface Client {
conn: any;
request: any;
}
}