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