Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
connect(): void {
invariant(
!this._isTerminated(),
'RSocketResumableTransport: Cannot connect(), connection terminated (%s: %s).',
this._status.kind,
this._status.kind === 'ERROR' ? this._status.error.message : 'no message',
);
try {
this._disconnect();
this._currentConnection = null;
this._receiveSubscription = null;
this._statusSubscription = null;
this._setConnectionStatus(CONNECTION_STATUS.CONNECTING);
const connection = this._source();
connection.connectionStatus().subscribe({
onNext: status => {
if (status.kind === this._status.kind) {
return;
}
if (status.kind === 'CONNECTED') {
if (this._sessionTimeoutHandle) {
clearTimeout(this._sessionTimeoutHandle);
this._sessionTimeoutHandle = null;
}
//Setup
if (this._setupFrame == null) {
this._handleConnected(connection);
//Resume
} else {
connect(): void {
invariant(
this.getConnectionState().kind === 'NOT_CONNECTED',
'RSocketTlsClient: Cannot connect(), a connection is already ' +
'established.',
);
this.setConnectionStatus(CONNECTION_STATUS.CONNECTING);
const socket = tls.connect(this._options);
this.setupSocket(socket);
socket.on('connect', this._handleOpened);
}
connect(): void {
invariant(
this._status.kind === 'NOT_CONNECTED',
'RSocketWebSocketClient: Cannot connect(), a connection is already ' +
'established.',
);
this._setConnectionStatus(CONNECTION_STATUS.CONNECTING);
const wsCreator = this._options.wsCreator;
const url = this._options.url;
this._socket = wsCreator ? wsCreator(url) : new WebSocket(url);
const socket = this._socket;
socket.binaryType = 'arraybuffer';
(socket.addEventListener: $FlowIssue)('close', this._handleClosed);
(socket.addEventListener: $FlowIssue)('error', this._handleError);
(socket.addEventListener: $FlowIssue)('open', this._handleOpened);
(socket.addEventListener: $FlowIssue)('message', this._handleMessage);
}