Uni*_*ech 6 javascript strophe
示例代码:
var connection = null;
function onConnect(status) {
im_a_big_error.log('wtf');
// Why it doesn't throw me an error here ??
}
$().ready(function() {
connection = new Strophe.Connection('http://localhost:8080/http-bind');
connection.connect('admin@localhost', 'admin', onConnect);
});
Run Code Online (Sandbox Code Playgroud)
它不会让我在Chrome控制台中出错.
你有想法解决这个问题吗?
是的,Strophe经常自己捕获错误,目前不提供任何获取连接错误信息的能力.虽然错误捕获是可以的,但是不能自己捕获错误也不是很好.但您可以使用以下代码修复它:
$().ready(function() {
connection = new Strophe.Connection('http://localhost:8080/http-bind');
connection._hitError = function (reqStatus) {
this.errors++;
Strophe.warn("request errored, status: " + reqStatus + ",
number of errors: " + this.errors);
if (this.errors > 4) this._onDisconnectTimeout();
myErrorHandler(reqStatus, this.errors);
};
connection.connect('admin@localhost', 'admin', onConnect);
});
Run Code Online (Sandbox Code Playgroud)
myErrorHandler您的自定义连接错误处理程序在哪里
| 归档时间: |
|
| 查看次数: |
2802 次 |
| 最近记录: |