Ionic 4 Невозможно получить доступ к «Клиенту» до инициализации в Module.createCliention - PullRequest
3 голосов
/ 27 мая 2019

Я использую stanza в ionic 4, после успешной установки, когда я пытался проверить соединение, он выдает ошибку, как ...

ionic 4 Невозможно получить доступ к «Клиенту» до инициализации в модуле.createClient

import * as XMPP from 'stanza';
export class StanzaTestPage implements OnInit {
  client: any;
  constructor() {
  }
  ngOnInit() {
      this.createConn();
  }
  createConn() {
    let that = this;
    this.client = XMPP.createClient({
      jid: 'testUser@testhost',
      password: 'Pass_123',
      transport: 'websocket',
      wsURL: 'ws://***:1234/websock',
      useStreamManagement: true
    });
    this.client.connect();
    this.client.enableKeepAlive(/* { interval: 30 } */);
    this.client.on('auth:failed', function (err) {
      console.log("auth:failed.......");
      console.log(err);
    });
    this.client.on('disconnected', function (err) {
      console.log("disconnected.......");
      console.log(err);
    });

    this.client.on('session:error', function (err) {
      console.log("session:error.......");
      console.log(err);

    });

    this.client.on('auth:success', function (con) {
      console.log("auth:success.......");
      console.log(con);

    });
    this.client.on('session:started', function () {
      console.log("Session Started.......");
      that.client.sendPresence();//sending our presense in server
    });
  }
}

enter image description here

...