How to use rsocket-websocket-client - 7 common examples

To help you get started, we’ve selected a few rsocket-websocket-client 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 linux-china / spring-boot-rsocket-demo / rsocket-react-demo / src / App.js View on Github external
initRsocketWebSocket() {
        // Create an instance of a client
        const client = new RSocketClient({
            //serializers: JsonSerializers,
            setup: {
                // ms btw sending keepalive to server
                keepAlive: 60000,
                // ms timeout if no keepalive response
                lifetime: 180000,
                // // format of `data`
                dataMimeType: 'application/json',
                // format of `metadata`
                metadataMimeType: 'x.rsocket.routing.v0',
            },
            transport: new RSocketWebSocketClient({url: 'ws://localhost:8088/rsocket'}),
        });

        // Open the connection
        client.connect().subscribe({
            onComplete: socket => {
                this.socket = socket;
            },
            onError: error => console.error(error),
            onSubscribe: cancel => {/* call cancel() to abort */
            }
        });

        setInterval(() => {
            let that = this;
            this.socket && this.socket.requestResponse({
                data: '' + (++index),
github scalecube / scalecube-js / packages / rsocket-ws-gateway / src / createGatewayProxy.ts View on Github external
return new Promise((resolve, reject) => {
    const client = new RSocketClient({
      serializers: JsonSerializers,
      setup: {
        dataMimeType: 'application/json',
        keepAlive: 100000,
        lifetime: 100000,
        metadataMimeType: 'application/json',
      },
      transport: new RSocketWebSocketClient({ url }),
    });
    client.connect().subscribe({
      onComplete: (socket: any) => {
        // console.log('Connected to ' + url);
        resolve(socket);
      },
      onError: (error: any) => {
        // console.log('Err', error);
        reject(new Error('Connection error'));
      },
    });
  });
};
github rsocket / rsocket-js / packages / rsocket-examples / src / CompositeMetadataExample.js View on Github external
const maxRSocketRequestN = 2147483647;
const host = '127.0.0.1';
const port = 7000;
const keepAlive = 60000;
const lifetime = 180000;
const dataMimeType = 'application/octet-stream';
const metadataMimeType = MESSAGE_RSOCKET_COMPOSITE_METADATA.string;

const client = new RSocketClient({
  setup: {
    keepAlive,
    lifetime,
    dataMimeType,
    metadataMimeType,
  },
  transport: new RSocketWebSocketClient(
    {wsCreator: () => new WebSocket('ws://localhost:7000'), debug: true},
    BufferEncoders,
  ),
});

// Open the connection
client.connect().then(socket => {
  socket
    .requestStream({
      data: new Buffer('request-stream'),
      metadata: encodeAndAddWellKnownMetadata(
        encodeAndAddCustomMetadata(
          Buffer.alloc(0),
          TEXT_PLAIN.string,
          Buffer.from('Hello World'),
        ),
github bclozel / spring-flights / flight-client / src / tracker.js View on Github external
constructor(url, responder) {
        this.client = new RSocketClient({
            serializers: {
                data: JsonSerializer,
                metadata: JsonMetadataSerializer,
            },
            setup: {
                // ms btw sending keepalive to server
                keepAlive: 10000,
                // ms timeout if no keepalive response
                lifetime: 20000,
                dataMimeType: 'application/json',
                metadataMimeType: JsonMetadataSerializer.MIME_TYPE,
            },
            transport: new RSocketWebSocketClient({url: url}),
            responder: responder
        });
    }
github rsocket / rsocket-js / packages / rsocket-examples / src / SimpleCli.js View on Github external
function getClientTransport(protocol: string, options: ServerOptions) {
  switch (protocol) {
    case 'tcp':
    default:
      return new RSocketTcpClient({...options});
    case 'ws':
      return new RSocketWebSocketClient({
        url: 'ws://' + options.host + ':' + options.port,
        wsCreator: url => {
          return new WebSocket(url);
        },
      });
  }
}
github art-community / ART / management-panel / src / main / web / src / api / PlatformClient.ts View on Github external
const connect = async () => new RSocketClient({
    setup: RSOCKET_OPTIONS,
    transport: new RSocketWebSocketClient({url: RSOCKET_URL}, BufferEncoders)
}).connect();
github scalecube / scalecube-js / packages / scalecube-transport / src / provider / RSocketClientProvider.js View on Github external
return new Promise((resolve, reject) => {
      const validationError = validateBuildConfig({ URI, keepAlive, lifetime, WebSocket });
      if (validationError) {
        return reject(new Error(validationError))
      }

      try {
        this._client = new RSocketClient({
          serializers: JsonSerializers,
          setup: {
            keepAlive,
            lifetime,
            dataMimeType: 'application/json',
            metadataMimeType: 'application/json'
          },
          transport: new RSocketWebSocketClient({ url: URI, wsCreator }),
        });
      } catch(error) {
        return reject(error);
      }

      this._connect()
        .then(resolve)
        .catch(error => reject(extractConnectionError(error)))
    });
  }

rsocket-websocket-client

RSocket WebSocket client for use in browser environments

Apache-2.0
Latest version published 9 months ago

Package Health Score

77 / 100
Full package analysis

Popular rsocket-websocket-client functions

Similar packages