我在 ionic 4 中使用节,在成功安装后,当我尝试测试连接时,它会抛出类似的错误......</p>
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
});
}
}