我在 ionic 4 中使用了节,成功安装后,当我尝试测试连接时,它会引发我的错误,例如……
离子 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);
}); …Run Code Online (Sandbox Code Playgroud)