Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function connect(options: Options): Promise> {
const client = new RSocketClient({
setup: {
dataMimeType: 'text/plain',
keepAlive: 1000000, // avoid sending during test
lifetime: 100000,
metadataMimeType: 'text/plain',
},
transport: new RSocketTcpClient({
host: options.host,
port: options.port,
}),
});
return new Promise((resolve, reject) => {
client.connect().subscribe({
onComplete: resolve,
onError: reject,
});
});
}
function getClientTransport(protocol: string, options: ServerOptions) {
switch (protocol) {
case 'tcp':
default:
return new RSocketTcpClient({...options});
case 'ws':
return new RSocketWebSocketClient({
url: 'ws://' + options.host + ':' + options.port,
wsCreator: url => {
return new WebSocket(url);
},
});
}
}
() => new RSocketTcpClient({host, port}, BufferEncoders),
{
const onConnection = (socket: net.Socket) => {
subscriber.onNext(new RSocketTcpConnection(socket, this._encoders));
};
subscriber.onSubscribe({