Beispiel #1
0
        private void CreateListener()
        {
            this.listener = SparkleListenerFactory.CreateListener(Name, Identifier);

            if (this.listener.IsConnected)
            {
                this.poll_interval = PollInterval.Long;

                new Thread(() => {
                    if (!this.is_syncing && !HasLocalChanges && HasRemoteChanges)
                    {
                        SyncDownBase();
                    }
                }).Start();
            }

            this.listener.Connected            += ListenerConnectedDelegate;
            this.listener.Disconnected         += ListenerDisconnectedDelegate;
            this.listener.AnnouncementReceived += ListenerAnnouncementReceivedDelegate;

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting)
            {
                this.listener.Connect();
            }
        }
Beispiel #2
0
        private void CreateListener()
        {
            this.listener = SparkleListenerFactory.CreateListener(Name, Identifier);

            if (this.listener.IsConnected)
            {
                this.poll_interval = PollInterval.Long;
            }

            this.listener.Disconnected         += ListenerDisconnectedDelegate;
            this.listener.AnnouncementReceived += ListenerAnnouncementReceivedDelegate;

            if (!this.listener.IsConnected && !this.listener.IsConnecting)
            {
                this.listener.Connect();
            }
        }
Beispiel #3
0
        public void CreateListener()
        {
            this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);

            if (this.listener.IsConnected) {
                this.poll_interval = this.long_interval;

                new Thread (new ThreadStart (delegate {
                    if (!IsSyncing && CheckForRemoteChanges ())
                        SyncDownBase ();
                })).Start ();
            }

            // Stop polling when the connection to the irc channel is succesful
            this.listener.Connected += delegate {
                this.poll_interval = this.long_interval;
                this.last_poll = DateTime.Now;

                if (!IsSyncing) {

                    // Check for changes manually one more time
                    if (CheckForRemoteChanges ())
                        SyncDownBase ();

                    // Push changes that were made since the last disconnect
                    if (HasUnsyncedChanges)
                        SyncUpBase ();
                }
            };

            // Start polling when the connection to the irc channel is lost
            this.listener.Disconnected += delegate {
                this.poll_interval = this.short_interval;
                SparkleHelpers.DebugInfo (Name, "Falling back to polling");
            };

            // Fetch changes when there is a message in the irc channel
            this.listener.Announcement += delegate (SparkleAnnouncement announcement) {
                string identifier = Identifier;

                if (announcement.FolderIdentifier.Equals (identifier) &&
                    !announcement.Message.Equals (CurrentRevision)) {

                    while (this.IsSyncing)
                        System.Threading.Thread.Sleep (100);

                    SparkleHelpers.DebugInfo ("Listener", "Syncing due to announcement");
                    SyncDownBase ();

                } else {
                    if (announcement.FolderIdentifier.Equals (identifier))
                        SparkleHelpers.DebugInfo ("Listener", "Not syncing, message is for current revision");
                }
            };

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting)
                this.listener.Connect ();
        }
Beispiel #4
0
        private void CreateListener ()
        {
            this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);

            if (this.listener.IsConnected) {
                this.poll_interval = PollInterval.Long;

                new Thread (() => {
                    if (!this.is_syncing && !HasLocalChanges && HasRemoteChanges)
                        SyncDownBase ();

                }).Start ();
            }

            this.listener.Connected            += ListenerConnectedDelegate;
            this.listener.Disconnected         += ListenerDisconnectedDelegate;
            this.listener.AnnouncementReceived += ListenerAnnouncementReceivedDelegate;

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting)
                this.listener.Connect ();
        }
        private void CreateListener ()
        {
            this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);

            if (this.listener.IsConnected)
                this.poll_interval = PollInterval.Long;

            this.listener.Connected            += ListenerConnectedDelegate;
            this.listener.Disconnected         += ListenerDisconnectedDelegate;
            this.listener.AnnouncementReceived += ListenerAnnouncementReceivedDelegate;

            if (!this.listener.IsConnected && !this.listener.IsConnecting)
                this.listener.Connect ();
        }
Beispiel #6
0
        public void CreateListener()
        {
            this.listener = SparkleListenerFactory.CreateListener (Name, Identifier);

            // Stop polling when the connection to the irc channel is succesful
            this.listener.Connected += delegate {
                this.poll_interval = this.long_interval;
                this.last_poll = DateTime.Now;

                // Check for changes manually one more time
                if (CheckForRemoteChanges ())
                    SyncDownBase ();

                // Push changes that were made since the last disconnect
                if (HasUnsyncedChanges)
                    SyncUpBase ();
            };

            // Start polling when the connection to the irc channel is lost
            this.listener.Disconnected += delegate {
                this.poll_interval = this.short_interval;
                SparkleHelpers.DebugInfo (Name, "Falling back to polling");
            };

            // Fetch changes when there is a message in the irc channel
            this.listener.Announcement += delegate (SparkleAnnouncement announcement) {
                string identifier = Identifier;

                if (announcement.FolderIdentifier == identifier &&
                    !announcement.Message.Equals (CurrentRevision)) {
                    if ((Status != SyncStatus.SyncUp)   &&
                        (Status != SyncStatus.SyncDown) &&
                        !this.is_buffering) {

                        while (this.listener.HasQueueDownAnnouncement (identifier))
                            SyncDownBase ();
                    }
                }
            };

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting) {
                this.listener.Connect ();
            }
        }
Beispiel #7
0
        public void CreateListener()
        {
            this.listener = SparkleListenerFactory.CreateListener(Name, Identifier);

            if (this.listener.IsConnected)
            {
                this.poll_interval = this.long_interval;

                new Thread(new ThreadStart(delegate {
                    if (!IsSyncing && CheckForRemoteChanges())
                    {
                        SyncDownBase();
                    }
                })).Start();
            }

            // Stop polling when the connection to the irc channel is succesful
            this.listener.Connected += delegate {
                this.poll_interval = this.long_interval;
                this.last_poll     = DateTime.Now;

                if (!IsSyncing)
                {
                    // Check for changes manually one more time
                    if (CheckForRemoteChanges())
                    {
                        SyncDownBase();
                    }

                    // Push changes that were made since the last disconnect
                    if (HasUnsyncedChanges)
                    {
                        SyncUpBase();
                    }
                }
            };

            // Start polling when the connection to the irc channel is lost
            this.listener.Disconnected += delegate {
                this.poll_interval = this.short_interval;
                SparkleHelpers.DebugInfo(Name, "Falling back to polling");
            };

            // Fetch changes when there is a message in the irc channel
            this.listener.Announcement += delegate(SparkleAnnouncement announcement) {
                string identifier = Identifier;

                if (announcement.FolderIdentifier.Equals(identifier) &&
                    !announcement.Message.Equals(CurrentRevision))
                {
                    while (this.IsSyncing)
                    {
                        System.Threading.Thread.Sleep(100);
                    }

                    SparkleHelpers.DebugInfo("Listener", "Syncing due to announcement");
                    SyncDownBase();
                }
                else
                {
                    if (announcement.FolderIdentifier.Equals(identifier))
                    {
                        SparkleHelpers.DebugInfo("Listener", "Not syncing, message is for current revision");
                    }
                }
            };

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting)
            {
                this.listener.Connect();
            }
        }
        private void CreateListener()
        {
            NotificationServerType server_type;
            if (UsesNotificationCenter)
                server_type = NotificationServerType.Central;
            else
                server_type = NotificationServerType.Own;

            this.listener = SparkleListenerFactory.CreateIrcListener (Domain, Identifier, server_type);

            // Stop polling when the connection to the irc channel is succesful
            this.listener.Connected += delegate {
                this.is_polling = false;

                // Check for changes manually one more time
                if (CheckForRemoteChanges ())
                    SyncDownBase ();

                // Push changes that were made since the last disconnect
                if (HasUnsyncedChanges)
                    SyncUpBase ();
            };

            // Start polling when the connection to the irc channel is lost
            this.listener.Disconnected += delegate {
                SparkleHelpers.DebugInfo (Name, "Falling back to polling");
                this.is_polling = true;
            };

            // Fetch changes when there is a message in the irc channel
            this.listener.RemoteChange += delegate (SparkleAnnouncement announcement) {
                string identifier = Identifier;

                if (announcement.FolderIdentifier == identifier &&
                    !announcement.Message.Equals (CurrentRevision)) {
                    if ((Status != SyncStatus.SyncUp)   &&
                        (Status != SyncStatus.SyncDown) &&
                        !this.is_buffering) {

                        while (this.listener.HasQueueDownAnnouncement (identifier))
                            SyncDownBase ();
                    }
                }
            };

            // Start listening
            if (!this.listener.IsConnected && !this.listener.IsConnecting)
                this.listener.Connect ();
            else
                this.is_polling = false;
        }