How to use @stomp/stompjs - 10 common examples

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 eclipse / vorto-examples / vorto-middleware / middleware-service / frontend / src / app / service / monitoring / websocket.service.ts View on Github external
public connect() {
    const socket = SocketFactory;
    this.stompClient = Stomp.Stomp.over(socket);
    this.stompClient.reconnectDelay = 5000;
    this.stompClient.heartbeatIncoming = 0; // Typical value 0 - disabled
    this.stompClient.heartbeatOutgoing = 20000; // Typical value 20000 - every 20 seconds
    const _this = this;
    this.stompClient.connect({}, function(frame) {
      console.log('Connected to websocket. Now subscribing: ' + frame);

      _this.stompClient.send('/middleware/endpoint/subscribe');

      let group = []

      _this.messageSubscription = _this.stompClient.subscribe('/topic/device/', function(response) {
        _this.messageActivity();
        const msg = JSON.parse(response.body);
        group = _this._correlatedMessages.value[msg.correlationId];
        if (group) {
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
github stomp-js / ng2-stompjs / dist / src / stomp.service.js View on Github external
StompService.prototype.initStompClient = function () {
        // Attempt connection, passing in a callback
        this.client = Stomp.client(this.config.url);
        // Configure client heart-beating
        this.client.heartbeat.incoming = this.config.heartbeat_in;
        this.client.heartbeat.outgoing = this.config.heartbeat_out;
        // Auto reconnect
        this.client.reconnect_delay = this.config.reconnect_delay;
        if (!this.config.debug) {
            this.debug = function () { };
        }
        // Set function to debug print messages
        this.client.debug = this.debug;
    };
    /**
github stomp-js / ng2-stompjs / dist / @stomp / ng2-stompjs.es5.js View on Github external
StompRService.prototype.initStompClient = function () {
        // disconnect if connected
        this.disconnect();
        // url takes precedence over socketFn
        if (typeof (this._config.url) === 'string') {
            this.client = client(this._config.url);
        }
        else {
            this.client = over(this._config.url);
        }
        // Configure client heart-beating
        this.client.heartbeat.incoming = this._config.heartbeat_in;
        this.client.heartbeat.outgoing = this._config.heartbeat_out;
        // Auto reconnect
        this.client.reconnect_delay = this._config.reconnect_delay;
        if (!this._config.debug) {
            this.debug = function () { };
        }
        // Set function to debug print messages
        this.client.debug = this.debug;
        // Default messages
        this.setupOnReceive();
github stomp-js / ng2-stompjs / dist / @stomp / ng2-stompjs.es5.js View on Github external
StompRService.prototype.initStompClient = function () {
        // disconnect if connected
        this.disconnect();
        // url takes precedence over socketFn
        if (typeof (this._config.url) === 'string') {
            this.client = client(this._config.url);
        }
        else {
            this.client = over(this._config.url);
        }
        // Configure client heart-beating
        this.client.heartbeat.incoming = this._config.heartbeat_in;
        this.client.heartbeat.outgoing = this._config.heartbeat_out;
        // Auto reconnect
        this.client.reconnect_delay = this._config.reconnect_delay;
        if (!this._config.debug) {
            this.debug = function () { };
        }
        // Set function to debug print messages
        this.client.debug = this.debug;
        // Default messages
        this.setupOnReceive();
        // Receipts
        this.setupReceipts();
    };
github bluecolor / octopus / frontend / src / store / modules / users.js View on Github external
listen ({commit}) {
    const socket = new SockJS('/socket')
    const stomp = Stomp.over(socket)
    stomp.connect({}, f => {
      stomp.subscribe(`/topic/task-instance-error`, d => {
        commit(NOTIFY_TASK_ERR, d)
      })
    }, e => {
      console.log(e)
    })
  },
  pollMe ({commit}) {
github WISE-Community / WISE / src / main / webapp / wise5 / classroomMonitor / src / polyfills.ts View on Github external
/***************************************************************************************************
 * APPLICATION IMPORTS
 */
import * as jQuery from 'jquery';
import * as fabric from 'fabric';
import * as StompJS from '@stomp/stompjs';
import * as SockJS from 'sockjs-client';
import * as Highcharts from '../../lib/highcharts/highcharts.src';
import * as hopscotch from 'hopscotch';
import * as EventEmitter2 from 'eventemitter2';

window['$'] = jQuery;
window['jQuery'] = jQuery;
window['fabric'] = fabric.fabric;
window['SockJS'] = SockJS;
window['Stomp'] = StompJS.Stomp;
window['hopscotch'] = hopscotch;
window['Highcharts'] = Highcharts;
window['EventEmitter2'] = EventEmitter2;
github WISE-Community / WISE / src / main / webapp / wise5 / authoringTool / src / polyfills.ts View on Github external
* APPLICATION IMPORTS
 */
import 'zone-blacklist.js';
import * as jQuery from 'jquery';
import * as fabric from 'fabric';
import * as StompJS from '@stomp/stompjs';
import * as SockJS from 'sockjs-client';
import * as Highcharts from '../../lib/highcharts/highcharts.src';
import * as hopscotch from 'hopscotch';
import * as EventEmitter2 from 'EventEmitter2';

window['$'] = jQuery;
window['jQuery'] = jQuery;
window['fabric'] = fabric.fabric;
window['SockJS'] = SockJS;
window['Stomp'] = StompJS.Stomp;
window['hopscotch'] = hopscotch;
window['Highcharts'] = Highcharts;
window['EventEmitter2'] = EventEmitter2;
import * as summernote from 'summernote';
window['summernote'] = summernote;
github WISE-Community / WISE / src / main / webapp / wise5 / vle / src / polyfills.ts View on Github external
*/
import * as jQuery from 'jquery';
import * as fabric from 'fabric';
import * as StompJS from '@stomp/stompjs';
import * as SockJS from 'sockjs-client';
import * as Highcharts from '../../lib/highcharts/highcharts.src';
import * as hopscotch from 'hopscotch';
import * as EventEmitter2 from 'eventemitter2';
import * as draggablePoints from '../../lib/draggable-points/draggable-points';
import * as HighchartsExporting from '../../lib/highcharts-exporting@4.2.1';

window['$'] = jQuery;
window['jQuery'] = jQuery;
window['fabric'] = fabric.fabric;
window['SockJS'] = SockJS;
window['Stomp'] = StompJS.Stomp;
window['hopscotch'] = hopscotch;
window['Highcharts'] = Highcharts;
window['EventEmitter2'] = EventEmitter2;
import * as summernote from 'summernote';
window['summernote'] = summernote;
window['draggablePoints'] = draggablePoints;
window['HighchartsExporting'] = HighchartsExporting;
github viadee / sonarQuest / sonarQuest-frontend / src / app / services / websocket.service.ts View on Github external
initializeWebSocketConnection() {
    this.closeWebSocket();

    const ws = new SockJS(this.serverUrl);
    this.stompClient = Stomp.over(ws);
    const that = this;
    this.stompClient.connect({}, function(frame) {
      this.chatStomp = that.stompClient.subscribe('/chat', message => {
        const eventUserDto: EventUserDto = JSON.parse(message.body);
        that.eventService.addEvent(eventUserDto);
      });
    });
  }

@stomp/stompjs

STOMP client for Javascript and Typescript

Apache-2.0
Latest version published 2 years ago

Package Health Score

59 / 100
Full package analysis