[repo] try to reconnect after connection is lost
This commit is contained in:
parent
473afa00df
commit
e5d064b0e3
|
@ -22,10 +22,12 @@ using System.Threading;
|
|||
|
||||
namespace SparkleLib {
|
||||
|
||||
// A persistent connection to the server that
|
||||
// listens for change notifications
|
||||
public class SparkleListener
|
||||
{
|
||||
|
||||
// FIXME: The irc client is a public property because
|
||||
// FIXME: The IrcClient is a public property because
|
||||
// extending it causes crashes
|
||||
public IrcClient Client;
|
||||
private Thread Thread;
|
||||
|
@ -49,9 +51,12 @@ namespace SparkleLib {
|
|||
Server = "irc.gnome.org";
|
||||
|
||||
Client = new IrcClient () {
|
||||
PingTimeout = 90,
|
||||
SocketSendTimeout = 90,
|
||||
SocketReceiveTimeout = 90
|
||||
PingTimeout = 60,
|
||||
SocketSendTimeout = 60,
|
||||
SocketReceiveTimeout = 60,
|
||||
AutoRetry = true,
|
||||
AutoReconnect = true,
|
||||
AutoRejoin = true
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -93,6 +98,7 @@ namespace SparkleLib {
|
|||
}
|
||||
|
||||
|
||||
// Frees all resources for this Listener
|
||||
public void Dispose ()
|
||||
{
|
||||
|
||||
|
|
|
@ -264,7 +264,7 @@ namespace SparkleLib {
|
|||
|
||||
_UserName = GetUserName ();
|
||||
_UserEmail = GetUserEmail ();
|
||||
_CurrentHash = GetCurrentHash ();
|
||||
_CurrentHash = GetCurrentHash ();
|
||||
_HasUnsyncedChanges = false;
|
||||
_IsSyncing = false;
|
||||
_IsBuffering = false;
|
||||
|
@ -297,6 +297,10 @@ namespace SparkleLib {
|
|||
Interval = 60000
|
||||
};
|
||||
|
||||
|
||||
// Listen to the irc channel on the server
|
||||
Listener = new SparkleListener (Domain, "#" + RemoteName, _UserEmail);
|
||||
|
||||
RemoteTimer.Elapsed += delegate {
|
||||
|
||||
CheckForRemoteChanges ();
|
||||
|
@ -304,10 +308,14 @@ namespace SparkleLib {
|
|||
if (_HasUnsyncedChanges)
|
||||
Push ();
|
||||
|
||||
};
|
||||
if (!Listener.Client.IsConnected) {
|
||||
|
||||
// Listen to the irc channel on the server
|
||||
Listener = new SparkleListener (Domain, "#" + RemoteName, _UserEmail);
|
||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Trying to reconnect...");
|
||||
Listener.Client.Reconnect (true, true);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Stop polling when the connection to the irc channel is succesful
|
||||
Listener.Client.OnConnected += delegate {
|
||||
|
|
|
@ -25,6 +25,8 @@ using System.Timers;
|
|||
|
||||
namespace SparkleShare {
|
||||
|
||||
// The statusicon that stays in the
|
||||
// user's notification area
|
||||
public class SparkleStatusIcon : StatusIcon
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in a new issue