connection
connection socket wrapper
Usage
Client Socket
const net = ;const awaitFirst = ;const Connection = ; const Decoder = ;const Encoder = ;// bolt protocol exampleconst protocol = name: 'Rpc' opts opts; { const socket = net; await ; return logger: console socket protocol ;} const conn = await ; conn;
Server Socket
const Connection = ;const server = net;server; server;
API
- oneway() - one way call
- async writeRequest(req) - write request and wait response
- async writeResponse(req, res) - write response
- async close() - wait all pending request done and destroy the socket
- async forceClose() - abort all pending request and destroy the socket
- get protocolOptions() - encoder/decoder constructor options, can be overwrite when custom protocol
Protocol implement