forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zmq.d.ts
218 lines (189 loc) · 4.98 KB
/
zmq.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
// Type definitions for ZeroMQ Node
// Project: https://github.com/JustinTulloss/zeromq.node
// Definitions by: Dave McKeown <http://github.com/davemckeown>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path='../node/node.d.ts' />
interface EventEmitter {}
declare module 'zmq' {
interface SocketTypes {
pub: number;
xpub: number;
sub: number;
xsub: number;
req: number;
xreq: number;
rep: number;
xrep: number;
push: number;
pull: number;
dealer: number;
router: number;
pair: number;
}
interface SocketOptions {
_fd: number;
_ioevents: number;
_receiveMore: number;
_subscribe: number;
_unsubscribe: number;
affinity: number;
backlog: number;
hwm: number;
identity: number;
linger: number;
mcast_loop: number;
rate: number;
rcvbuf: number;
last_endpoint: number;
reconnect_ivl: number;
recovery_ivl: number;
sndbuf: number;
swap: number;
}
interface Socket extends EventEmitter {
/**
* Set `opt` to `val`.
*
* @param opt Option
* @param val Value
*/
setsocketopt(opt: number, val: any): Socket;
/**
* Set `opt` to `val`.
*
* @param opt Option
* @param val Value
*/
setsocketopt(opt: string, val: any): Socket;
/**
* Get socket `opt`.
*
* @param opt Option number
*/
getsocketopt(opt: number): any;
/**
* Get socket `opt`.
*
* @param opt Option string
*/
getsocketopt(opt: string): any;
/**
* Async bind.
*
* Emits the "bind" event.
*
* @param addr Socket address
* @param cb Bind callback
*/
bind(addr: string, callback?: (error: string) => void ): Socket;
/**
* Sync bind.
*
* @param addr Socket address
*/
bindSync(addr: string): Socket;
/**
* Async unbind.
*
* Emits the "unbind" event.
*
* @param addr Socket address
* @param cb Unind callback
*/
unbind(addr: string, callback?: (error: string) => void ): Socket;
/**
* Sync unbind.
*
* @param addr Socket address
*/
unbindSync(addr: string): Socket;
/**
* Connect to `addr`.
*
* @param addr Connection address
*/
connect(addr: string): Socket;
/**
* Disconnect from `addr`.
*
* @param addr The address
*/
disconnect(addr: string): Socket;
/**
* Subscribe with the given `filter`.
*
* @param filter The filter
*/
subscribe(filter: string): Socket;
/**
* Unsubscribe with the given `filter`.
*
* @param filter The filter
*/
unsubscribe(filter: string): Socket;
/**
* Send the given `msg`.
*
* @param msg The message
* @param flags Message flags
*/
send(msg: string, flags?: number): Socket;
/**
* Send the given `msg`.
*
* @param msg {Buffer} The message
* @param flags {number} Optional message flags
*/
send(msg: Buffer, flags?: number): Socket;
/**
* Send the given `msg`.
*
* @param msg The message
* @param flags Message flags
*/
send(msg: any[], flags?: number): Socket;
/**
* Enable monitoring of a Socket
*
* @param {Number} timer interval in ms > 0 or Undefined for default
* @return {Socket} for chaining
*/
monitor(interval?: number): Socket;
/**
* Close the socket.
*
*/
close(): Socket;
/**
* Socket event
* @param eventName {string}
* @param callback {Function}
*/
on(eventName: string, callback: (...buffer: Buffer[]) => void): void;
// Socket Options
_fd: any;
_ioevents: any;
_receiveMore: any;
_subscribe: any;
_unsubscribe: any;
affinity: any;
backlog(): any;
hwm: any;
identity: any;
linger: any;
mcast_loop: any;
rate: any;
rcvbuf: any;
last_endpoint: any;
reconnect_ivl: any;
recovery_ivl: any;
sndbuf: any;
swap: any;
}
export var version: string;
export var types: SocketTypes;
export var options: SocketOptions;
function socket(type: string, options?: any): Socket;
function socket(type: number, options?: any): Socket;
function createSocket(type: string, options?: any): Socket;
}