abstract class TcpSocket {
constructor(socket: Socket)
netSocket
socket: Socket
connect(port: number, host: string)
on(event: string, callback: (err?: any) => void)
once(event: string, callback: (err?: any) => void)
end()
sendMessage(message: any, callback?: (err?: any) => void)
protected abstract handleSend(message: any, callback?: (err?: any) => void)
protected abstract handleData(data: string | Buffer)
protected emitMessage(data: string)
}
Constructor
constructor(socket: Socket)
Parameters
Option |
Type |
Description |
socket
|
Socket |
|
|
Properties
Property |
Description |
netSocket
|
Read-only.
|
socket: Socket
|
Read-only.
Declared in constructor.
|
Methods
connect()
|
connect(port: number, host: string)
Parameters
Option |
Type |
Description |
port
|
number |
|
host
|
string |
|
|
on()
|
on(event: string, callback: (err?: any) => void)
Parameters
Option |
Type |
Description |
event
|
string |
|
callback
|
(err?: any) => void |
|
|
once()
|
once(event: string, callback: (err?: any) => void)
Parameters
Option |
Type |
Description |
event
|
string |
|
callback
|
(err?: any) => void |
|
|
end()
|
end()
Parameters
There are no parameters.
|
sendMessage()
|
sendMessage(message: any, callback?: (err?: any) => void)
Parameters
Option |
Type |
Description |
message
|
any |
|
callback
|
(err?: any) => void |
Optional. Default is undefined .
|
|
handleSend()
|
protected abstract handleSend(message: any, callback?: (err?: any) => void)
Parameters
Option |
Type |
Description |
message
|
any |
|
callback
|
(err?: any) => void |
Optional. Default is undefined .
|
|
handleData()
|
protected abstract handleData(data: string | Buffer)
Parameters
Option |
Type |
Description |
data
|
string | Buffer |
|
|
emitMessage()
|
protected emitMessage(data: string)
Parameters
Option |
Type |
Description |
data
|
string |
|
|