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;
const closeSocket = () => {
if (!initialized) {
//Setup
if (this._setupFrame == null) {
this._handleConnected(connection);
//Resume
} else {
this._handleResume(connection);
}
} else if (this._isTerminationStatus(status)) {
if (!this._sessionTimeoutHandle) {
this._sessionTimeoutHandle = setTimeout(
() => this._close(this._resumeTimeoutError()),
this._sessionTimeoutMillis,
);
}
this._disconnect();
this._setConnectionStatus(CONNECTION_STATUS.NOT_CONNECTED);
}
},
onSubscribe: subscription => {
this._position = {
client: 0,
server: 0,
};
this._currentConnection = null;
this._statusSubscription = null;
this._receiveSubscription = null;
this._receivers = new Set();
this._resumeToken = options.resumeToken;
this._sessionTimeoutMillis = options.sessionDurationSeconds * 1000;
this._sessionTimeoutHandle = null;
this._senders = new Set();
this._sentFrames = [];
this._setupFrame = null;
this._source = source;
this._status = CONNECTION_STATUS.NOT_CONNECTED;
this._statusSubscribers = new Set();
}
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;
}
}
constructor(options: ClientOptions, encoders: ?Encoders<*>) {
this._encoders = encoders;
this._options = options;
this._receivers = new Set();
this._senders = new Set();
this._socket = null;
this._status = CONNECTION_STATUS.NOT_CONNECTED;
this._statusSubscribers = new Set();
}