Ignore:
Timestamp:
Dec 16, 2009, 5:55:00 PM (12 years ago)
Author:
Matthäus Wander
Message:

P2P:

  • implemented Equals and GetHashCode in PeerId
  • changed accessibility of PeerId variables to private -> lead to some refactoring
  • changed PeerId constructor to read ID from p@p OverlayAddress
  • added wrapper methods to retrieve OverlayAddress by byte[] id from p@p

Became some more complex than expected. It compiles and I hope it still works.

File:
1 edited

Legend:

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

    r1012 r1022  
    9393        {
    9494            SendMessage(actualPublisher, PubSubMessageType.Solution);
    95             this.p2pControl.SendToPeer(sSolutionData, actualPublisher.byteId);
     95            this.p2pControl.SendToPeer(sSolutionData, actualPublisher.ToByteArray());
    9696        }
    9797        /* END: Only for experimental cases */
     
    134134        private void MessageReceived(PeerId sourceAddr, string sData)
    135135        {
    136             if (sourceAddr.stringId != actualPublisher.stringId)
    137             {
    138                 GuiLogging("RECEIVED message from third party peer (not the publisher!): " + sData.Trim() + ", ID: " + sourceAddr.stringId, NotificationLevel.Debug);
     136            if (sourceAddr != actualPublisher)
     137            {
     138                GuiLogging("RECEIVED message from third party peer (not the publisher!): " + sData.Trim() + ", ID: " + sourceAddr, NotificationLevel.Debug);
    139139                return;
    140140            }
     
    225225        protected virtual void HandleIncomingData(PeerId senderId, string sData)
    226226        {
    227             GuiLogging("RECEIVED: Message from '" + senderId.stringId
     227            GuiLogging("RECEIVED: Message from '" + senderId
    228228                    + "' with data: '" + sData + "'", NotificationLevel.Debug);
    229229
     
    311311            sendAliveMessageInterval = System.BitConverter.ToInt32(byteISettings, 0);
    312312
    313             string sPubId = this.p2pControl.ConvertIdToString(bytePubId);
    314             GuiLogging("RECEIVED: Publishers' peer name '" + sPubId + "', Alive-Msg-Interval: " + sendAliveMessageInterval / 1000 + " sec!", NotificationLevel.Debug);
    315 
    316             pid = new PeerId(sPubId, bytePubId);
     313            pid = this.p2pControl.GetPeerID(bytePubId);
    317314            if (actualPublisher == null) //first time initialization
    318315                actualPublisher = pid;
     316
     317            GuiLogging("RECEIVED: Publishers' peer name '" + pid + "', Alive-Msg-Interval: " + sendAliveMessageInterval / 1000 + " sec!", NotificationLevel.Debug);
    319318
    320319            // setting timer to check periodical the availability of the publishing peer
     
    340339                return;
    341340            }
    342             if (newPubId.stringId != actualPublisher.stringId)
     341            if (newPubId != actualPublisher)
    343342            {
    344343                //Handle case, when publisher changed or isn't active at present (don't reply on response)
    345                 GuiLogging("CHANGED: Publisher from '" + actualPublisher.stringId
    346                     + "' to '" + newPubId.stringId + "'!", NotificationLevel.Info);
     344                GuiLogging("CHANGED: Publisher from '" + actualPublisher
     345                    + "' to '" + newPubId + "'!", NotificationLevel.Info);
    347346                actualPublisher = newPubId;
    348347                // because the publisher has changed, send a new register msg
Note: See TracChangeset for help on using the changeset viewer.