как сохранить связь с wesocket-соединением, используя stomp / sock js in angular 6 - PullRequest
0 голосов
/ 25 февраля 2019

Я хочу сохранить в живых то соединение с веб-сокетом, как только оно будет установлено.Приведенный ниже код предназначен для установки соединения, но не для его активации

  connectWebSocket(token) {
    const socket = new SockJS('url');
    this.stompClient = Stomp.over(socket);

    const _this = this;
    _this.stompClient.connect({"token" : token, "api_version": 2}, function (frame) {


    console.log('WebSocket: - ' + frame);

    _this.stompClient.subscribe('/topic/notify/' + token, function(notification){
      console.log('WebSocket: - Notification - ', notification.body);
      _this.info.lastUpdateTime = new Date();
      //ToDo: Need to wrinte a message service that will handle the web socket response.
      _this.messageProcessorService.process(notification.body);        
    });  

    _this.announce(token);      

    });
  } 
...