1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00
Yaaic/application/src/org/yaaic/model/Broadcast.java
Steven Luo bce2523f98 Fix auto-reconnect
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.
2011-06-29 20:34:55 +02:00

74 lines
2.4 KiB
Java

/*
Yaaic - Yet Another Android IRC Client
Copyright 2009-2011 Sebastian Kaspari
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.model;
import android.content.Intent;
/**
* Constants and helpers for Broadcasts
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*/
public abstract class Broadcast
{
public static final String SERVER_UPDATE = "org.yaaic.server.status";
public static final String SERVER_RECONNECT = "org.yaaic.server.reconnect.";
public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message";
public static final String CONVERSATION_NEW = "org.yaaic.conversation.new";
public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove";
public static final String CONVERSATION_TOPIC = "org.yaaic.conversation.topic";
/**
* Create an Intent for conversation broadcasting
*
* @param broadcastType The type of the broadcast, some constant of Broadcast.*
* @param serverId The id of the server
* @param conversationName The unique name of the conversation
* @return The created Intent
*/
public static Intent createConversationIntent(String broadcastType, int serverId, String conversationName)
{
Intent intent = new Intent(broadcastType);
intent.putExtra(Extra.SERVER, serverId);
intent.putExtra(Extra.CONVERSATION, conversationName);
return intent;
}
/**
* Create an Intent for server broadcasting
*
* @param broadcastType The typo of the broadcast, some constant of Broadcast.*
* @param serverId The id of the server
* @return The created Intent
*/
public static Intent createServerIntent(String broadcastType, int serverId)
{
Intent intent = new Intent(broadcastType);
intent.putExtra(Extra.SERVER, serverId);
return intent;
}
}