forked from bitfocus/companion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcp.d.ts
36 lines (31 loc) · 953 Bytes
/
tcp.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
/// <reference types="node" />
import { EventEmitter } from 'events'
/**
* A TCP client wrapper
* Events emitted:
* - 'error' when an error occurs
* - 'status_change' when the connection status changes. Valid values are STATUS_OK, STATUS_WARNING and STATUS_ERROR (as found on instance_skel)
* - 'connect' when the connection has opened
* - 'end' when the socket has ended
* - 'data' when a packet of data has been received
* - 'drain' when the write buffer has emptied
*/
declare class TCPClient extends EventEmitter {
constructor(
host: string,
port: number,
options?: {
/** default 2000 */
reconnect_interval?: number
/** default true */
reconnect?: boolean
}
)
/** Force a reconnection attempt */
connect(): void
/** Write a message to the socket */
write(message: string | Buffer, cb: (err: Error | undefined) => void): void
/** Shutdown and cleanup the socket */
destroy(): void
}
export = TCPClient