How to use rxjs-websockets - 7 common examples

To help you get started, we’ve selected a few rxjs-websockets 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 cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / features / applications / deploy-application / deploy-application-deployer.ts View on Github external
tap(([appDetail, org, space]) => {
        this.cfGuid = appDetail.cloudFoundryDetails.cloudFoundry;
        this.orgGuid = appDetail.cloudFoundryDetails.org;
        this.spaceGuid = appDetail.cloudFoundryDetails.space;
        this.applicationSource = appDetail.applicationSource;
        this.applicationOverrides = appDetail.applicationOverrides;
        const host = window.location.host;
        const streamUrl = (
          `wss://${host}/pp/${this.proxyAPIVersion}/${this.cfGuid}/${this.orgGuid}/${this.spaceGuid}/deploy` +
          `?org=${org.entity.name}&space=${space.entity.name}`
        );

        this.inputStream = new Subject();
        this.messages = websocketConnect(streamUrl, this.inputStream)
          .pipe(
            catchError(e => {
              return [];
            }),
            map(message => {
              const json = JSON.parse(message);
              return json;
            }),
            filter(l => !!l),
            tap((log) => {
              // Deal with control messages
              if (log.type !== SocketEventTypes.DATA) {
                this.processWebSocketMessage(log);
              }
            }),
            filter((log) => log.type === SocketEventTypes.DATA),
github cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / features / applications / application / application-tabs-base / tabs / log-stream-tab / log-stream-tab.component.ts View on Github external
ngOnInit() {
    this.connectionStatus.next(0);
    if (!this.applicationService.cfGuid || !this.applicationService.appGuid) {
      this.messages = NEVER;
    } else {
      const host = window.location.host;
      const streamUrl = `wss://${host}/pp/v1/${
        this.applicationService.cfGuid
        }/apps/${this.applicationService.appGuid}/stream`;

      const socket$ = makeWebSocketObservable(streamUrl);
      socket$.pipe(catchError(e => {
        this.logService.error(
          'Error while connecting to socket: ' + JSON.stringify(e)
        );
        return [];
      }),
        share(),
        filter(data => !!data && data.length)
      );

      this.messages = socket$.pipe(
        switchMap((getResponses: GetWebSocketResponses) => {
          this.connectionStatus.next(1);
          return getResponses(new Subject());
        }),
        map((message: string) => message),
github cloudfoundry / stratos / src / frontend / packages / core / src / features / cloud-foundry / tabs / cloud-foundry-firehose / cloud-foundry-firehose.component.ts View on Github external
private setupFirehoseStream(streamUrl: string) {
    const { messages, connectionStatus } = websocketConnect(
      streamUrl,
      new Subject()
    );

    this.messages = messages;
    this.connectionStatus = connectionStatus;
    messages.pipe(
      catchError(e => {
        return [];
      }),
      share(),
      filter(l => !!l)
    );
  }
}
github cloudfoundry / stratos / src / frontend / packages / cloud-foundry / src / features / cloud-foundry / tabs / cloud-foundry-firehose / cloud-foundry-firehose.component.ts View on Github external
private setupFirehoseStream(streamUrl: string) {
    const { messages, connectionStatus } = websocketConnect(
      streamUrl,
      new Subject()
    );

    this.messages = messages;
    this.connectionStatus = connectionStatus;
    messages.pipe(
      catchError(e => {
        return [];
      }),
      share(),
      filter(l => !!l)
    );
  }
}
github cloudfoundry / stratos / src / frontend / packages / core / src / features / applications / ssh-application / ssh-application.component.ts View on Github external
this.appInstanceLink = (
      `/applications/${cfGuid}/${appGuid}/instances`
    );

    if (!cfGuid || !appGuid || !this.instanceId) {
      this.messages = NEVER;
      this.connectionStatus = NEVER;
    } else {
      const host = window.location.host;
      const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws';
      const streamUrl = (
        `${protocol}://${host}/pp/v1/${cfGuid}/apps/${appGuid}/ssh/${this.instanceId}`
      );
      this.sshInput = new Subject();
      const connection = websocketConnect(
        streamUrl,
        this.sshInput
      );

      this.messages = connection.messages.pipe(
        catchError(e => {
          if (e.type === 'error') {
            this.errorMessage = 'Error connecting to web socket';
          }
          return [];
        }));

      this.connectionStatus = connection.connectionStatus;

      this.breadcrumbs$ = this.applicationService.waitForAppEntity$.pipe(
        map(app => this.getBreadcrumbs(app.entity.entity)),
github AltCoinExchange / altcoin-atomic-trading-platform / altcoinio / src / app / services / order-matching.service.ts View on Github external
public connect() {
    if (this.messages) {
      return;
    }

    this.messages = websocketConnect(
      environment.wsOrderApi + '/orders',
      this.inputStream = new QueueingSubject()
    ).messages.share();
  }
github cloudfoundry / stratos / src / frontend / app / features / cloud-foundry / tabs / cloud-foundry-firehose / cloud-foundry-firehose.component.ts View on Github external
private setupFirehoseStream(streamUrl: string) {
    const { messages, connectionStatus } = websocketConnect(
      streamUrl,
      new Subject()
    );

    this.messages = messages;
    this.connectionStatus = connectionStatus;
    messages.pipe(
      catchError(e => {
        return [];
      }),
      share(),
      filter(l => !!l)
    );
  }
}

rxjs-websockets

rxjs 7 websockets library

ISC
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular rxjs-websockets functions