How to use the rsocket-core.RSocketServer function in rsocket-core

To help you get started, we’ve selected a few rsocket-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scalecube / scalecube-js / packages / rsocket-ws-gateway / src / Gateway.ts View on Github external
public start(opts: GatewayStartOptions) {
    if (this.started) {
      this.warn('Gateway is already started');
      return;
    }
    const { serviceCall } = opts;
    validateServiceCall(serviceCall);

    this.server = new RSocketServer({
      serializers: JsonSerializers,
      getRequestHandler: (socket) => {
        return {
          requestResponse: (payload: RsocketEventsPayload) =>
            requestResponse(payload, serviceCall, this.requestResponse),
          requestStream: (payload: RsocketEventsPayload) => requestStream(payload, serviceCall, this.requestStream),
        };
      },
      transport: this.transport,
    });
    this.server.start();
    // console.log('Gateway started on port: ' + this.port);
    this.started = true;
  }
github rsocket / rsocket-js / packages / rsocket-examples / src / SimpleCli.js View on Github external
async function run(options) {
  const serverOptions = {
    host: options.host,
    port: options.port,
  };

  if (!isClient) {
    const deferred = new Deferred();
    const server = new RSocketServer({
      getRequestHandler: socket => {
        runOperation(socket, options);
        return new SymmetricResponder();
      },
      transport: getServerTransport(options.protocol, serverOptions),
    });
    server.start();

    console.log(`Server started on ${options.host}:${options.port}`);
    return deferred.getPromise();
  } else {
    console.log(`Client connecting to ${options.host}:${options.port}`);
    // $FlowFixMe
    const socket: ReactiveSocket = await connect(
      options.protocol,
      serverOptions,
github facebook / flipper / src / server.tsx View on Github external
console.error(`Error opening server on port ${port}`, 'server');
            reject(err);
          })
          .on('listening', () => {
            console.debug(
              `${
                sslConfig ? 'Secure' : 'Certificate'
              } server started on port ${port}`,
              'server',
            );
            server.emit('listening', port);
            resolve(rsServer);
          });
        return transportServer;
      };
      rsServer = new RSocketServer({
        getRequestHandler: sslConfig
          ? this._trustedRequestHandler
          : this._untrustedRequestHandler,
        transport: new RSocketTCPServer({
          port: port,
          serverFactory: serverFactory,
        }),
      });
      rsServer && rsServer.start();
    });
  }
github facebook / flipper / src / server.tsx View on Github external
console.error(`Error opening server on port ${port}`, 'server');
            reject(err);
          })
          .on('listening', () => {
            console.debug(
              `${
                sslConfig ? 'Secure' : 'Certificate'
              } server started on port ${port}`,
              'server',
            );
            server.emit('listening', port);
            resolve(rsServer);
          });
        return transportServer;
      };
      rsServer = new RSocketServer({
        getRequestHandler: sslConfig
          ? this._trustedRequestHandler
          : this._untrustedRequestHandler,
        transport: new RSocketTCPServer({
          port: port,
          serverFactory: serverFactory,
        }),
      });
      rsServer && rsServer.start();
    });
  }
github rsocket / rsocket-js / packages / rsocket-examples / src / SimpleServer.js View on Github external
async function run(options) {
  const deferred = new Deferred();

  const serverOptions: ServerOptions = {
    host: options.host,
    port: options.port,
  };

  let server = new RSocketServer({
    getRequestHandler: payload => {
      return new Responder();
    },
    transport: getTransport(options.protocol, serverOptions),
  });
  server.start();

  console.log(`Server started on ${options.host}:${options.port}`);

  return deferred.getPromise();
}
github scalecube / scalecube-js / packages / scalecube-transport / src / server / server.js View on Github external
}
        case '/greeting/failing/one': {
          responseData = getFailingOneResponse(data);
          break;
        }
        case '/greeting/pojo/one': {
          responseData = { text: getTextResponseSingle(data.text) };
          break;
        }
      }
      resolve({ data: responseData })
    }, 100);
  });
};

const server = new RSocketServer({
  getRequestHandler: (socket) => {
    return {
      requestResponse({ data, metadata: { q } }) {
        return new Single(subscriber => {
          requestResponseHandler(data, q).then(response => subscriber.onComplete(response));
          subscriber.onSubscribe();
        });
      },
      requestStream({ data, metadata: { q } }) {
        return new Flowable(subscriber => {
          let index = 0;
          let isStreamCanceled = false;
          subscriber.onSubscribe({
            cancel: () => { isStreamCanceled = true },
            request: n => {
              if (q.includes('/one')) {