Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
requestResponse(
payload: Payload,
): Single> {
const method: string = this._getMethod(payload);
const spanContext = deserializeTraceData(this._tracer, payload.metadata);
return this._getMetricsWrapper(false, method)(
this._getTracingWrapper(false, method)(spanContext)(
new Single(subscriber => {
const {data, metadata} = this._marshaller.unmarshall(payload);
return (
this._handler[method](data, metadata)
.map(this._marshaller.marshall)
// $FlowFixMe
.subscribe(subscriber)
);
}),
),
);
}
constructor(config: ClientConfig, connection: DuplexConnection) {
this._machine = createClientMachine(
connection,
subscriber => connection.receive().subscribe(subscriber),
config.serializers,
config.responder,
);
// Send SETUP
connection.sendOne(this._buildSetupFrame(config));
// Send KEEPALIVE frames
const {keepAlive} = config.setup;
const keepAliveFrames = every(keepAlive).map(() => ({
data: null,
flags: FLAGS.RESPOND,
lastReceivedPosition: 0,
streamId: CONNECTION_STREAM_ID,
type: FRAME_TYPES.KEEPALIVE,
}));
connection.send(keepAliveFrames);
}
this._machine = createClientMachine(
connection,
subscriber => connection.receive().subscribe(subscriber),
lifetime,
config.serializers,
config.responder,
config.errorHandler,
requesterLeaseHandler,
responderLeaseHandler,
);
// Send SETUP
connection.sendOne(this._buildSetupFrame(config));
// Send KEEPALIVE frames
const keepAliveFrames = every(keepAlive).map(() => ({
data: null,
flags: FLAGS.RESPOND,
lastReceivedPosition: 0,
streamId: CONNECTION_STREAM_ID,
type: FRAME_TYPES.KEEPALIVE,
}));
connection.send(keepAliveFrames);
}
metadataPush(payload: Payload): Single {
let error: ?Error;
if (this._responder.metadataPush) {
try {
return this._responder.metadataPush(payload);
} catch (_error) {
console.error('metadataPush threw an exception', _error);
error = _error;
}
}
return Single.error(error || new Error('not implemented'));
}
}
requestResponse(payload: Payload): Single> {
let error: ?Error;
if (this._responder.requestResponse) {
try {
return this._responder.requestResponse(payload);
} catch (_error) {
console.error('requestResponse threw an exception', _error);
error = _error;
}
}
return Single.error(error || new Error('not implemented'));
}
requestChannel(payloads: Flowable>): Flowable> {
let error: ?Error;
if (this._responder.requestChannel) {
try {
return this._responder.requestChannel(payloads);
} catch (_error) {
console.error('requestChannel threw an exception', _error);
error = _error;
}
}
return Flowable.error(error || new Error('not implemented'));
}
requestStream(payload: Payload): Flowable> {
let error: ?Error;
if (this._responder.requestStream) {
try {
return this._responder.requestStream(payload);
} catch (_error) {
console.error('requestStream threw an exception', _error);
error = _error;
}
}
return Flowable.error(error || new Error('not implemented'));
}
function doOperation(
socket: ReactiveSocket,
operation: string,
payload: string,
): Flowable> {
switch (operation) {
case 'none':
return Flowable.never();
case 'stream':
default:
console.log(`Requesting stream with payload: ${payload}`);
return socket.requestStream({
data: payload,
metadata: '',
});
}
}
rank: function(rankingRequest, metadata){
rankingRequest.getRecordsList().forEach(record => {
console.log(record.getId() + " " + record.getData().getSupername());
});
console.log("....");
let resp = new RankingResponse();
resp.setId(rankingRequest.getRecordsList()[0].getId());
return Single.of(resp);
}
};
connectionStatus(): Flowable {
return new Flowable(subscriber => {
subscriber.onSubscribe({
cancel: () => {
this._statusSubscribers.delete(subscriber);
},
request: () => {
this._statusSubscribers.add(subscriber);
subscriber.onNext(this._status);
},
});
});
}