[repo] Add a simple notification queue when disconnected, and send them when reconnected.
This commit is contained in:
parent
e609c0b3a4
commit
7bcefc9831
|
@ -24,25 +24,19 @@ namespace SparkleLib {
|
|||
|
||||
public SparkleGit (string path, string args) : base ()
|
||||
{
|
||||
|
||||
EnableRaisingEvents = true;
|
||||
StartInfo.FileName = SparklePaths.GitPath;
|
||||
StartInfo.Arguments = args;
|
||||
StartInfo.RedirectStandardOutput = true;
|
||||
StartInfo.UseShellExecute = false;
|
||||
StartInfo.WorkingDirectory = path;
|
||||
|
||||
}
|
||||
|
||||
|
||||
new public void Start ()
|
||||
{
|
||||
|
||||
SparkleHelpers.DebugInfo ("Cmd", StartInfo.FileName + " " + StartInfo.Arguments);
|
||||
base.Start ();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,8 @@ namespace SparkleLib {
|
|||
private Timer LocalTimer;
|
||||
private FileSystemWatcher Watcher;
|
||||
private System.Object ChangeLock;
|
||||
private int FetchRequests;
|
||||
private int FetchQueue;
|
||||
private int AnnounceQueue;
|
||||
private SparkleListener Listener;
|
||||
private List <double> SizeBuffer;
|
||||
private bool HasChanged;
|
||||
|
@ -134,7 +135,6 @@ namespace SparkleLib {
|
|||
{
|
||||
LocalPath = path;
|
||||
Name = Path.GetFileName (LocalPath);
|
||||
|
||||
RemoteOriginUrl = GetRemoteOriginUrl ();
|
||||
RemoteName = Path.GetFileNameWithoutExtension (RemoteOriginUrl);
|
||||
Domain = GetDomain (RemoteOriginUrl);
|
||||
|
@ -149,7 +149,8 @@ namespace SparkleLib {
|
|||
_ServerOnline = true;
|
||||
HasChanged = false;
|
||||
ChangeLock = new Object ();
|
||||
FetchRequests = 0;
|
||||
FetchQueue = 0;
|
||||
AnnounceQueue = 0;
|
||||
|
||||
if (IsEmpty)
|
||||
_CurrentHash = null;
|
||||
|
@ -216,6 +217,12 @@ namespace SparkleLib {
|
|||
Push ();
|
||||
|
||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Connected. Now listening... (" + Listener.Server + ")");
|
||||
|
||||
if (AnnounceQueue > 0) {
|
||||
Listener.Announce (_CurrentHash);
|
||||
AnnounceQueue = 0;
|
||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Queued messages delivered. (" + Listener.Server + ")");
|
||||
}
|
||||
};
|
||||
|
||||
// Start polling when the connection to the irc channel is lost
|
||||
|
@ -236,12 +243,12 @@ namespace SparkleLib {
|
|||
string message = args.Data.Message.Trim ();
|
||||
|
||||
if (!message.Equals (_CurrentHash) && message.Length == 40) {
|
||||
FetchRequests++;
|
||||
FetchQueue++;
|
||||
|
||||
if (!_IsFetching) {
|
||||
while (FetchRequests > 0) {
|
||||
while (FetchQueue > 0) {
|
||||
Fetch ();
|
||||
FetchRequests--;
|
||||
FetchQueue--;
|
||||
}
|
||||
|
||||
Watcher.EnableRaisingEvents = false;
|
||||
|
@ -666,8 +673,12 @@ namespace SparkleLib {
|
|||
if (PushingFinished != null)
|
||||
PushingFinished (this, args);
|
||||
|
||||
if (!_IsPolling)
|
||||
if (Listener.Client.IsConnected) {
|
||||
Listener.Announce (_CurrentHash);
|
||||
} else {
|
||||
AnnounceQueue++;
|
||||
SparkleHelpers.DebugInfo ("Irc", "[" + Name + "] Could not deliver notification, added it to the queue");
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue