bit more sync/listener logic
This commit is contained in:
parent
3d4a8b5f9d
commit
448e39924d
|
@ -153,7 +153,7 @@ namespace SparkleLib {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("Listener",
|
SparkleHelpers.DebugInfo ("Listener",
|
||||||
"Already received or sent message " + announcement.Message + " to " + announcement.FolderIdentifier + " on " + this.server);
|
"Already processed message " + announcement.Message + " to " + announcement.FolderIdentifier + " on " + this.server);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ namespace SparkleLib {
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Got message " + announcement.Message + " from " + announcement.FolderIdentifier + " on " + this.server);
|
SparkleHelpers.DebugInfo ("Listener", "Got message " + announcement.Message + " from " + announcement.FolderIdentifier + " on " + this.server);
|
||||||
|
|
||||||
if (this.IsRecentAnnounement(announcement) ){
|
if (this.IsRecentAnnounement(announcement) ){
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Ignoring previously received message " + announcement.Message + " from " + announcement.FolderIdentifier + " on " + this.server);
|
SparkleHelpers.DebugInfo ("Listener", "Ignoring previously processed message " + announcement.Message + " from " + announcement.FolderIdentifier + " on " + this.server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,11 +93,14 @@ namespace SparkleLib {
|
||||||
|
|
||||||
if (bytes_read > 0) {
|
if (bytes_read > 0) {
|
||||||
string received = Encoding.UTF8.GetString (bytes);
|
string received = Encoding.UTF8.GetString (bytes);
|
||||||
string folder_identifier = received.Substring (0, received.IndexOf ("!"));
|
string line = received.Substring (0, received.IndexOf ("\n"));
|
||||||
string message = this.CleanMessage (received.Substring (received.IndexOf ("!") + 1));
|
if (!line.Contains ("!"))
|
||||||
if (!message.Equals("connected..."))
|
continue;
|
||||||
|
string folder_identifier = line.Substring (0, line.IndexOf ("!"));
|
||||||
|
string message = this.CleanMessage (line.Substring (line.IndexOf ("!") + 1));
|
||||||
|
if (!folder_identifier.Equals("debug") &&
|
||||||
|
!String.IsNullOrEmpty(message))
|
||||||
OnAnnouncement (new SparkleAnnouncement (folder_identifier, message));
|
OnAnnouncement (new SparkleAnnouncement (folder_identifier, message));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SparkleHelpers.DebugInfo ("ListenerTcp", "Error on socket");
|
SparkleHelpers.DebugInfo ("ListenerTcp", "Error on socket");
|
||||||
|
|
||||||
|
|
|
@ -260,7 +260,7 @@ namespace SparkleLib {
|
||||||
!announcement.Message.Equals (CurrentRevision)) {
|
!announcement.Message.Equals (CurrentRevision)) {
|
||||||
|
|
||||||
while (this.IsSyncing ()) {
|
while (this.IsSyncing ()) {
|
||||||
//nothing just wait
|
System.Threading.Thread.Sleep (100);
|
||||||
}
|
}
|
||||||
SparkleHelpers.DebugInfo ("Listener", "Syncing due to Announcement");
|
SparkleHelpers.DebugInfo ("Listener", "Syncing due to Announcement");
|
||||||
if (!announcement.Message.Equals (CurrentRevision))
|
if (!announcement.Message.Equals (CurrentRevision))
|
||||||
|
@ -448,6 +448,7 @@ namespace SparkleLib {
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.SyncDown);
|
SyncStatusChanged (SyncStatus.SyncDown);
|
||||||
|
|
||||||
|
string pre_sync_revision = CurrentRevision;
|
||||||
if (SyncDown ()) {
|
if (SyncDown ()) {
|
||||||
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Done");
|
SparkleHelpers.DebugInfo ("SyncDown", "[" + Name + "] Done");
|
||||||
this.server_online = true;
|
this.server_online = true;
|
||||||
|
@ -455,6 +456,7 @@ namespace SparkleLib {
|
||||||
if (SyncStatusChanged != null)
|
if (SyncStatusChanged != null)
|
||||||
SyncStatusChanged (SyncStatus.Idle);
|
SyncStatusChanged (SyncStatus.Idle);
|
||||||
|
|
||||||
|
if (pre_sync_revision != CurrentRevision) {
|
||||||
List<SparkleChangeSet> change_sets = GetChangeSets (1);
|
List<SparkleChangeSet> change_sets = GetChangeSets (1);
|
||||||
if (change_sets != null && change_sets.Count > 0) {
|
if (change_sets != null && change_sets.Count > 0) {
|
||||||
SparkleChangeSet change_set = change_sets [0];
|
SparkleChangeSet change_set = change_sets [0];
|
||||||
|
@ -475,6 +477,7 @@ namespace SparkleLib {
|
||||||
NewChangeSet (change_set);
|
NewChangeSet (change_set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// There could be changes from a resolved
|
// There could be changes from a resolved
|
||||||
// conflict. Tries only once, then lets
|
// conflict. Tries only once, then lets
|
||||||
|
|
Loading…
Reference in a new issue