/
socket.d.ts
148 lines (148 loc) · 3.05 KB
/
socket.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import Emitter from "component-emitter";
import { Manager } from "./manager";
export declare class Socket extends Emitter {
readonly io: Manager;
id: string;
connected: boolean;
disconnected: boolean;
private readonly nsp;
private readonly auth;
private ids;
private acks;
private receiveBuffer;
private sendBuffer;
private flags;
private subs;
/**
* `Socket` constructor.
*
* @api public
*/
constructor(io: any, nsp: any, opts: any);
/**
* Subscribe to open, close and packet events
*
* @api private
*/
subEvents(): void;
/**
* "Opens" the socket.
*
* @api public
*/
open(): this;
connect(): this;
/**
* Sends a `message` event.
*
* @return {Socket} self
* @api public
*/
send(): this;
/**
* Override `emit`.
* If the event is in `events`, it's emitted normally.
*
* @param {String} event name
* @return {Socket} self
* @api public
*/
emit(ev: any): this;
/**
* Sends a packet.
*
* @param {Object} packet
* @api private
*/
packet(packet: any): void;
/**
* Called upon engine `open`.
*
* @api private
*/
onopen(): void;
/**
* Called upon engine `close`.
*
* @param {String} reason
* @api private
*/
onclose(reason: any): void;
/**
* Called with socket packet.
*
* @param {Object} packet
* @api private
*/
onpacket(packet: any): void;
/**
* Called upon a server event.
*
* @param {Object} packet
* @api private
*/
onevent(packet: any): void;
/**
* Produces an ack callback to emit with an event.
*
* @api private
*/
ack(id: any): () => void;
/**
* Called upon a server acknowlegement.
*
* @param {Object} packet
* @api private
*/
onack(packet: any): void;
/**
* Called upon server connect.
*
* @api private
*/
onconnect(id: string): void;
/**
* Emit buffered events (received and emitted).
*
* @api private
*/
emitBuffered(): void;
/**
* Called upon server disconnect.
*
* @api private
*/
ondisconnect(): void;
/**
* Called upon forced client/server side disconnections,
* this method ensures the manager stops tracking us and
* that reconnections don't get triggered for this.
*
* @api private.
*/
destroy(): void;
/**
* Disconnects the socket manually.
*
* @return {Socket} self
* @api public
*/
close(): this;
disconnect(): this;
/**
* Sets the compress flag.
*
* @param {Boolean} if `true`, compresses the sending data
* @return {Socket} self
* @api public
*/
compress(compress: any): this;
/**
* Sets the binary flag
*
* @param {Boolean} whether the emitted data contains binary
* @return {Socket} self
* @api public
*/
binary(binary: any): this;
}