Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(socket: ws.Socket, encoders: ?Encoders<*>) {
this._active = true;
this._close = new Deferred();
this._encoders = encoders;
this._socket = socket;
this._statusSubscribers = new Set();
if (socket) {
this._status = CONNECTION_STATUS.CONNECTED;
} else {
this._status = CONNECTION_STATUS.NOT_CONNECTED;
}
// If _receiver has been `subscribe()`-ed already
let isSubscribed = false;
this._receiver = new Flowable(subscriber => {
invariant(
!isSubscribed,
'RSocketWebSocketServer: Multicast receive() is not supported. Be sure ' +
'to receive/subscribe only once.',
);
isSubscribed = true;
// Whether `request()` has been called.
let initialized = false;
_handleConnected(connection: DuplexConnection): void {
this._currentConnection = connection;
this._flushFrames();
this._setConnectionStatus(CONNECTION_STATUS.CONNECTED);
connection.receive().subscribe({
onNext: frame => {
try {
this._receiveFrame(frame);
} catch (error) {
this._close(error);
}
},
onSubscribe: subscription => {
this._receiveSubscription = subscription;
subscription.request(Number.MAX_SAFE_INTEGER);
},
});
}
_handleOpened = (): void => {
this._setConnectionStatus(CONNECTION_STATUS.CONNECTED);
};
constructor(socket: ?net$Socket, encoders: ?Encoders<*>) {
this._buffer = createBuffer(0);
this._encoders = encoders;
this._receivers = new Set();
this._senders = new Set();
this._statusSubscribers = new Set();
if (socket) {
this.setupSocket(socket);
this._status = CONNECTION_STATUS.CONNECTED;
} else {
this._socket = null;
this._status = CONNECTION_STATUS.NOT_CONNECTED;
}
}
_handleOpened = (): void => {
this.setConnectionStatus(CONNECTION_STATUS.CONNECTED);
};
}