Ignore:
Timestamp:
Nov 2, 2009, 7:35:09 PM (12 years ago)
Author:
arnold
Message:

P2P Classes updated (Remove, Base) and removed old P2P Classes (P2PStore, P2PLoad)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerBase/PeerToPeerBase.cs

    r797 r813  
    3636/*
    3737 * Synchronous functions successfully tested (store, retrieve)
     38 * !!! remove-Function is faulty !!!
    3839 * Standard connection for test issues is LocalMachineBootstrapper.
    3940 * IrcBootstrapper also works, but it's to lame for testing issues!
    4041 *
    4142 * TODO:
     43 * - Add enums (BS,LinkManager,Overlay) to class - make it public to use in cross-cutting classes
    4244 * - dht.Remove-Method makes problems... "ArgumentNotNullException"
    4345 *   event though the Parameter is correctly set to a valid value!
    4446 *   --> forwarded to the p@p-Team
    4547 * - Testing asynchronous methods incl. EventHandlers
    46  *
    47  * TO DO in Related Projects:
    48  * - Change stand-alone P2P-Apps to IControl-Slaves from one P2P-Master (store, load, (remove))
    4948 */
    5049namespace Cryptool.Plugins.PeerToPeer
     
    117116        /// <param name="sUserName">Choose an individual name for the user</param>
    118117        /// <param name="sWorldName">fundamental: two peers are only in the SAME P2P system, when they initialized the SAME WORLD!</param>
     118        /// <param name="linkManagerType"></param>
     119        /// <param name="bsType"></param>
     120        /// <param name="overlayType"></param>
     121        /// <param name="dhtType"></param>
     122        public void InitializeAll(string sUserName, string sWorldName, P2PLinkManagerType linkManagerType, P2PBootstrapperType bsType, P2POverlayType overlayType, P2PDHTType dhtType)
     123        {
     124            #region Setting LinkManager, Bootstrapper, Overlay and DHT to the specified types
     125            switch (linkManagerType)
     126            {
     127                case P2PLinkManagerType.Snal:
     128                    //snal = secure network abstraction layer
     129                    this.linkmanager = new Snal();
     130                    break;
     131                default:
     132                    throw (new NotImplementedException());
     133                    break;
     134            }
     135            switch (bsType)
     136            {
     137                case P2PBootstrapperType.LocalMachineBootstrapper:
     138                    //LocalMachineBootstrapper = only local connection (runs only on one machine)
     139                    this.bootstrapper = new LocalMachineBootstrapper();
     140                    break;
     141                case P2PBootstrapperType.IrcBootstrapper:
     142                    this.bootstrapper = new IrcBootstrapper();
     143                    break;
     144                default:
     145                    throw (new NotImplementedException());
     146                    break;
     147            }
     148            switch (overlayType)
     149            {
     150                case P2POverlayType.FullMeshOverlay:
     151                    // changing overlay example: this.overlay = new ChordOverlay();
     152                    this.overlay = new FullMeshOverlay();
     153                    break;
     154                default:
     155                    throw (new NotImplementedException());
     156                    break;
     157            }
     158            switch (dhtType)
     159            {
     160                case P2PDHTType.FullMeshDHT:
     161                    this.dht = new FullMeshDHT();
     162                    break;
     163                default:
     164                    throw (new NotImplementedException());
     165                    break;
     166            }
     167            #endregion
     168
     169            this.dht.Initialize(sUserName, sWorldName, this.overlay, this.bootstrapper, this.linkmanager, null);
     170
     171            this.dht.MessageReceived += new EventHandler<MessageReceived>(OnDHT_MessageReceived);
     172            this.dht.SystemJoined += new EventHandler(OnDHT_SystemJoined);
     173            this.dht.SystemLeft += new EventHandler(OnDHT_SystemLeft);
     174        }
     175
     176        /// <summary>
     177        /// Initializing is the first step to build a new or access an existing p2p network
     178        /// </summary>
     179        /// <param name="sUserName">Choose an individual name for the user</param>
     180        /// <param name="sWorldName">fundamental: two peers are only in the SAME P2P system, when they initialized the SAME WORLD!</param>
    119181        public void Initialize(string sUserName, string sWorldName)
    120182        {
     
    203265        #endregion
    204266
     267        // not tested and not sure that this function return the right PeerName...
     268        /// <summary>
     269        /// Get PeerName of the actual peer
     270        /// </summary>
     271        /// <returns>Peer name of the actual peer</returns>
     272        public string GetPeerName()
     273        {
     274            return this.overlay.LocalAddress.ToString();
     275        }
     276
    205277        #region Event Handling (System Joined, Left and Message Received)
    206278
     
    216288            if (OnSystemLeft != null)
    217289                OnSystemLeft();
     290            // as an experiment
     291            this.dht = null;
    218292            this.systemLeft.Set();
    219293        }
Note: See TracChangeset for help on using the changeset viewer.