How to use the @stomp/stompjs.Client function in @stomp/stompjs

To help you get started, we’ve selected a few @stomp/stompjs 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 akarasev / stomp-spring-react / src / App.js View on Github external
componentDidMount() {
    console.log('Component did mount');
    // The compat mode syntax is totally different, converting to v5 syntax
    // Client is imported from '@stomp/stompjs'
    this.client = new Client();

    this.client.configure({
      brokerURL: 'ws://localhost:8080/stomp',
      onConnect: () => {
        console.log('onConnect');

        this.client.subscribe('/queue/now', message => {
          console.log(message);
          this.setState({serverTime: message.body});
        });

        this.client.subscribe('/topic/greetings', message => {
          alert(message.body);
        });
      },
      // Helps during debugging, remove in production

@stomp/stompjs

STOMP client for Javascript and Typescript

Apache-2.0
Latest version published 1 year ago

Package Health Score

63 / 100
Full package analysis