forked from pocmo/Yaaic
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The current auto-reconnection implementation will only try reconnecting once, immediately after the server is disconnected. This will of course almost always fail if the network is down or otherwise unavailable, so as it stands, enabling auto-reconnect isn't particularly useful. This patch implements multiple retries for auto-reconnect, with the frequency of retries controlled by a preference. The Android alarm infrastructure is used to schedule reconnection attempts; if the phone misses a scheduled attempt while it's asleep, the reconnection will be attempted the next time the phone wakes up.
- Loading branch information
Showing
8 changed files
with
187 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
Yaaic - Yet Another Android IRC Client | ||
Copyright 2009-2011 Sebastian Kaspari | ||
Copyright 2011 Steven Luo | ||
This file is part of Yaaic. | ||
Yaaic is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Yaaic is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Yaaic. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.yaaic.receiver; | ||
|
||
import org.yaaic.irc.IRCService; | ||
import org.yaaic.model.Broadcast; | ||
import org.yaaic.model.Server; | ||
|
||
import android.content.BroadcastReceiver; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
|
||
/** | ||
* A receiver to listen for alarms and start a reconnect attempt | ||
* | ||
* @author Steven Luo <[email protected]> | ||
*/ | ||
public class ReconnectReceiver extends BroadcastReceiver | ||
{ | ||
private IRCService service; | ||
private Server server; | ||
|
||
/** | ||
* Create a new reconnect receiver | ||
* | ||
* @param server The server to reconnect to | ||
*/ | ||
public ReconnectReceiver(IRCService service, Server server) | ||
{ | ||
this.service = service; | ||
this.server = server; | ||
} | ||
|
||
/** | ||
* On receive broadcast | ||
*/ | ||
@Override | ||
public void onReceive(Context context, Intent intent) | ||
{ | ||
if (!intent.getAction().equals(Broadcast.SERVER_RECONNECT + server.getId())) { | ||
return; | ||
} | ||
service.connect(server); | ||
} | ||
} |