Recently in the push, the adoption of the framework is ANDROIDPN, but for the client is really a modification can not stand, especially the reconnection and connection that piece, some bug modification is difficult to start, such as in the reconnection there, the original writing is in the dead loop constantly call Xmppmanager connection login, so , even if the reconnection succeeds, it will continue to join the reconnection task (connect, register, log in) every 20 seconds, and then continue to execute. Shows that this is very wasteful to the CPU and so on. In addition, I want to join the interface so that clients using it can get the current state, such as disconnecting, connecting, or logged in. Do not want to put the Xmppmanager object directly to expose at the same time the inside of the relevant methods are modified to public.
For these reasons, the final decision is to override the connection mechanism.
After rewriting, because of the differences with the original project is too big, not good with the fork of the project to merge again, on GitHub built another project.
The rewritten content includes:
1, based on the original version has been changed a number of bugs to modify, so this version basically can repair the internet most people mentioned the bug.
2, the re-connected process is changed to a broadcasting mechanism. Because it is an in-app broadcast and cannot conflict with broadcasts from other applications, Localbroadcastmanager is used for broadcasts related to this process.
3, do not use the original thread pool, because it is a single-threaded to perform the connection, registration and login these tasks (implementation of the Runnable interface Class), so a handler. Then, the connection, registration, login is written in the same task, but only divided into three methods (I seem to fall into the author's misunderstanding, these three processes are not parallel, it is linear, one by one, and is related, Why write three runnable and then go to the end to notify the other runnable to do it? )。
Currently rewritten, one version is available, hosted on GitHub: Https://github.com/msdx/APNBB.
Now that there are other projects busy, the project will not be changed for the time being.
Future plans include:
1, clean up the code (re-based on the broadcast mechanism, just rewrite the part of the re-connected, there are some other places to change. And to clean out some of the method variables that are no longer used.
2, connection, registration, login is no longer divided into three runnable objects.
3, avoid the lock screen when the thread hangs method, from the request power lock to use Alarmmanager.
APNBB based on ANDROIDPN client modifications