gpt4 book ai didi

android - aSmack,如何强制重新连接?

转载 作者:太空狗 更新时间:2023-10-29 15:01:00 26 4
gpt4 key购买 nike

我有一个 aSmack 实现的应用程序,(8-4.0.5),据我们所知,它有一个内部重新连接管理,但它并不令人满意,因为有时我们应该等待 5 分钟才能重新连接,而我们现在知道这是一个这样做的好时机,所以我已经实现了这个:

private BroadcastReceiver mConnReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
intent.getParcelableExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO);
if(isNetworkAvailable()){
if(MyService.myServiceInstance!=null){
if(!MyService.connection.isConnected() || !MyService.connection.isAuthenticated()){
MyService.myServiceInstance.performReconnect();
// Which goes to Connect() and Authenticate()
}
}
LMApplication.getInstance().getPresistentJobManager().onNetworkChange(true);
}

}
};

但问题是有时他们都尝试同时连接(我的经理和内置经理),结果是,他们下次一次又一次地重新连接,每次我都收到此错误:

11-10 14:58:09.069: W/PacketWriter(26439): Exception writing closing stream element
11-10 14:58:09.069: W/PacketWriter(26439): java.io.IOException: BufferedWriter is
closed
11-10 14:58:09.069: W/PacketWriter(26439): at
java.io.BufferedWriter.checkNotClosed(BufferedWriter.java:130)
11-10 14:58:09.069: W/PacketWriter(26439): at
java.io.BufferedWriter.flush(BufferedWriter.java:122)
11-10 14:58:09.069: W/PacketWriter(26439): at
org.jivesoftware.smack.util.ObservableWriter.flush(ObservableWriter.java:44)
11-10 14:58:09.069: W/PacketWriter(26439): at
org.jivesoftware.smack.tcp.PacketWriter.writePackets(PacketWriter.java:190)
11-10 14:58:09.069: W/PacketWriter(26439): at
org.jivesoftware.smack.tcp.PacketWriter.access$000(PacketWriter.java:40)
11-10 14:58:09.069: W/PacketWriter(26439): at
org.jivesoftware.smack.tcp.PacketWriter$1.run(PacketWriter.java:77)

我猜是因为 1 已经完成工作并关闭了编写器,而另一个看到编写器已关闭,断开连接!就像两个嫉妒的 child !

那么我能在这里做什么,比如如何禁用影响或强制重新连接?

最佳答案

我不得不删除 Samack 自动重新连接系统,我完全自己做了,这样我的应用程序就获得了稳定性。

关于android - aSmack,如何强制重新连接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26843087/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com