Ionic 4在Module.createCliention初始化之前无法访问“客户端”

时间:2019-05-27 04:51:26

标签: ionic-framework ionic4 stanza.io stanza

我在Ionic 4中使用stanza,在成功安装后,当我尝试测试连接时,它会向我抛出类似...的错误

ionic 4在Module.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

0 个答案:

没有答案