Ignore:
Timestamp:
Jan 20, 2010, 5:46:29 PM (12 years ago)
Author:
arnold
Message:

First testable version of network-comprehensive DES-Bruteforcing with P2PMAnager and P2PWorker.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerSubscriber/P2PSubscriberBase.cs

    r1098 r1100  
    119119            // if bolStopped = true, the Timer for Checking Publishers liveliness doesn't start
    120120            this.bolStopped = false;
    121             PeerId pubId = CheckPublisherAvailability();
    122             // if DHT Entry for Task is empty, there exist no Publisher at present.
    123             // The method PublisherIsAlive starts a Timer for this case to continous proof Publisher-DHT-Entry
    124             if (pubId != null)
    125             {
    126                 SendMessage(pubId, PubSubMessageType.Register);
    127                 if (this.timeoutForPublishersRegAccept == null)
    128                     this.timeoutForPublishersRegAccept = new Timer(OnTimeoutRegisteringAccepted, null, this.publisherReplyTimespan, this.publisherReplyTimespan);
    129                 this.started = true;
    130             }
    131             else
     121            PeerId pubId = CheckPublishersAvailability();
     122            // if DHT Entry for the task is empty, no Publisher exists at present.
     123            // The method CheckPublishersAvailability starts a Timer for this case to continous proof Publisher-DHT-Entry
     124            if (pubId == null)
    132125            {
    133126                this.Started = false;
    134127                // if PubId is null, the Publisher isn't started!
    135128                this.bolStopped = true;
    136             }
     129                GuiLogging("No publisher for registering found.", NotificationLevel.Info);
     130                return;
     131            }
     132
     133            // when the actual publisher differs from the new detected publisher, change it
     134            if (pubId != null && (actualPublisher != null && actualPublisher != pubId))
     135            {
     136                GuiLogging("Publisher has been changed from ID '" + actualPublisher + "' to '" + pubId + "'", NotificationLevel.Debug);
     137                actualPublisher = pubId;
     138            }
     139            SendMessage(pubId, PubSubMessageType.Register);
     140            if (this.timeoutForPublishersRegAccept == null)
     141                this.timeoutForPublishersRegAccept = new Timer(OnTimeoutRegisteringAccepted, null, this.publisherReplyTimespan, this.publisherReplyTimespan);
     142            this.started = true;
    137143        }
    138144
     
    254260        private void OnRegisteringNotPossible(object state)
    255261        {
    256             PeerId pubId = CheckPublisherAvailability();
    257             // if DHT Entry for Task is empty, there exist no Publisher at present.
    258             // The method PublisherIsAlive starts a Timer for this case to continous proof Publisher-DHT-Entry
    259             if (pubId != null)
    260                 SendMessage(pubId, PubSubMessageType.Register);
    261             else
    262                 GuiLogging("No publisher for registering found.", NotificationLevel.Info);
     262            Register();
    263263        }
    264264
     
    275275        /// </summary>
    276276        /// <returns>the actual Publishers ID or null, when a publisher wasn't found in the DHT</returns>
    277         private PeerId CheckPublisherAvailability()
     277        private PeerId CheckPublishersAvailability()
    278278        {
    279279            PeerId pid = DHT_CommonManagement.GetTopicsPublisherId(ref this.p2pControl, this.sTopic);
     
    287287                }
    288288                GuiLogging("Publisher wasn't found in DHT or settings didn't stored on the right way.", NotificationLevel.Debug);
    289                 //GuiLogging("Publisher wasn't found in DHT or settings didn't stored on the right way.", NotificationLevel.Warning);
    290289                return null;
    291290            }
     
    303302                actualPublisher = pid;
    304303                GuiLogging("First time received publishers ID.", NotificationLevel.Debug);
    305             }
    306             else if (actualPublisher != pid)
    307             {
    308                 GuiLogging("Publisher has been changed from ID '" +  actualPublisher + "' to '" + pid + "'", NotificationLevel.Debug);
    309                 actualPublisher = pid;
    310                 // because the publisher has changed, send a new register msg
    311                 SendMessage(actualPublisher, PubSubMessageType.Register);
    312304            }
    313305
     
    329321        private void OnCheckPubAvailability(object state)
    330322        {
    331             PeerId newPubId = CheckPublisherAvailability();
     323            PeerId newPubId = CheckPublishersAvailability();
    332324
    333325            if (newPubId == actualPublisher)
     
    367359            }
    368360            // try to get an active publisher and re-register
    369             CheckPublisherAvailability();
     361            CheckPublishersAvailability();
    370362        }
    371363
Note: See TracChangeset for help on using the changeset viewer.