3

i'm using aSmack in my Android app to receive messages from my Desktop-Jabber-client. This works fine and even if my android phone is offline (after the connection was closed properly) it will receive the offline messages after the next login.

But when i enter the airplane-mode on the phone or shutdown the phone so that the connection is abruptly closed (without calling disconnect() on the Connection-object) the phone stays "online" in the contact-list of my Desktop-Jabber-client for a while and i can send messages to it. However these messages never arrive. Even though the phone logs in to the server again. These messages are lost.

Does anyone know how to fix this issue? Losing messages in a chat is not an option. :)

EDIT: Added Test-Code
BroadcastReceiver: http://pastebin.com/cFLzGXgy
Service: http://pastebin.com/wLpQCQfT

The first one is a BroadcastReceiver starting the service (second URL) each time the phone is connected to a network.

PS: This is only a test-code! You must change the server/username/password if you want to use/test it.

4

3 回答 3

4

当消息到达时,您可以尝试将传递的消息从客户端 b 发送到客户端 A。问题是如果客户端 A 离线(没有连接中断),则在用户收到消息并且客户端 B 无法重新发送消息之前,不会发送传递的确认。

于 2012-03-21T11:10:49.620 回答
1

当您的连接中断时会出现此问题。您需要启用“流管理”XEP-198 的连接来实现此消息。参考这个博客: http: //op-co.de/blog/posts/XEP-0198/基本上它允许节确认和流恢复,这正是你想要做的,所以你应该等到smack将 4.1 发布。

于 2014-12-24T08:25:15.317 回答
1

您可以尝试使用 Smackx消息事件发送接收消息的确认, 这将确保消息已传递,否则您将采取纠正措施。

于 2011-12-28T18:47:56.680 回答