repo: When listening, make poll interval long for every repo
This commit is contained in:
parent
478ff8b33d
commit
1100fa205b
|
@ -165,7 +165,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public void OnConnected ()
|
public void OnConnected ()
|
||||||
{
|
{
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Connected to " + Server);
|
SparkleHelpers.DebugInfo ("Listener", "Listening for announcements on " + Server);
|
||||||
|
|
||||||
if (Connected != null)
|
if (Connected != null)
|
||||||
Connected ();
|
Connected ();
|
||||||
|
@ -185,7 +185,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
public void OnDisconnected ()
|
public void OnDisconnected ()
|
||||||
{
|
{
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Disonnected from " + Server);
|
SparkleHelpers.DebugInfo ("Listener", "Signal of " + Server + " lost");
|
||||||
|
|
||||||
if (Disconnected != null)
|
if (Disconnected != null)
|
||||||
Disconnected ();
|
Disconnected ();
|
||||||
|
|
|
@ -126,6 +126,7 @@ namespace SparkleLib {
|
||||||
|
|
||||||
while (HasUnsyncedChanges)
|
while (HasUnsyncedChanges)
|
||||||
SyncUpBase ();
|
SyncUpBase ();
|
||||||
|
|
||||||
EnableWatching ();
|
EnableWatching ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,11 +233,20 @@ namespace SparkleLib {
|
||||||
{
|
{
|
||||||
this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);
|
this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);
|
||||||
|
|
||||||
|
if (this.listener.IsConnected) {
|
||||||
|
this.poll_interval = this.long_interval;
|
||||||
|
|
||||||
|
if (!IsSyncing && CheckForRemoteChanges ())
|
||||||
|
SyncDownBase ();
|
||||||
|
}
|
||||||
|
|
||||||
// Stop polling when the connection to the irc channel is succesful
|
// Stop polling when the connection to the irc channel is succesful
|
||||||
this.listener.Connected += delegate {
|
this.listener.Connected += delegate {
|
||||||
this.poll_interval = this.long_interval;
|
this.poll_interval = this.long_interval;
|
||||||
this.last_poll = DateTime.Now;
|
this.last_poll = DateTime.Now;
|
||||||
|
|
||||||
|
if (!IsSyncing) {
|
||||||
|
|
||||||
// Check for changes manually one more time
|
// Check for changes manually one more time
|
||||||
if (CheckForRemoteChanges ())
|
if (CheckForRemoteChanges ())
|
||||||
SyncDownBase ();
|
SyncDownBase ();
|
||||||
|
@ -244,6 +254,7 @@ namespace SparkleLib {
|
||||||
// Push changes that were made since the last disconnect
|
// Push changes that were made since the last disconnect
|
||||||
if (HasUnsyncedChanges)
|
if (HasUnsyncedChanges)
|
||||||
SyncUpBase ();
|
SyncUpBase ();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start polling when the connection to the irc channel is lost
|
// Start polling when the connection to the irc channel is lost
|
||||||
|
@ -259,30 +270,30 @@ namespace SparkleLib {
|
||||||
if (announcement.FolderIdentifier.Equals (identifier) &&
|
if (announcement.FolderIdentifier.Equals (identifier) &&
|
||||||
!announcement.Message.Equals (CurrentRevision)) {
|
!announcement.Message.Equals (CurrentRevision)) {
|
||||||
|
|
||||||
while (this.IsSyncing ()) {
|
while (this.IsSyncing)
|
||||||
System.Threading.Thread.Sleep (100);
|
System.Threading.Thread.Sleep (100);
|
||||||
}
|
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Syncing due to Announcement");
|
SparkleHelpers.DebugInfo ("Listener", "Syncing due to announcement");
|
||||||
if (!announcement.Message.Equals (CurrentRevision))
|
|
||||||
SyncDownBase ();
|
SyncDownBase ();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (announcement.FolderIdentifier.Equals (identifier))
|
if (announcement.FolderIdentifier.Equals (identifier))
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Not syncing message is for current revision");
|
SparkleHelpers.DebugInfo ("Listener", "Not syncing, message is for current revision");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Start listening
|
// Start listening
|
||||||
if (!this.listener.IsConnected && !this.listener.IsConnecting) {
|
if (!this.listener.IsConnected && !this.listener.IsConnecting)
|
||||||
this.listener.Connect ();
|
this.listener.Connect ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private bool IsSyncing {
|
||||||
|
get {
|
||||||
|
return (Status == SyncStatus.SyncUp ||
|
||||||
|
Status == SyncStatus.SyncDown ||
|
||||||
|
this.is_buffering);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private bool IsSyncing ()
|
|
||||||
{
|
|
||||||
if (Status == SyncStatus.SyncUp || Status == SyncStatus.SyncDown || this.is_buffering)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue