Ignore:
Timestamp:
Jun 10, 2010, 1:39:21 PM (12 years ago)
Author:
Paul Lelgemann
Message:

o CrypP2P: Code cleanup
o P2PEditor: job list will be reloaded in a BackgroundWorker

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerBaseProxy/P2PPeer.cs

    r1611 r1616  
    8282        public bool PeerStarted()
    8383        {
    84             return P2PManager.Instance.IsP2PConnected() && !P2PManager.Instance.IsP2PConnecting;
     84            return P2PManager.IsConnected && !P2PManager.IsConnecting;
    8585        }
    8686
     
    8888        {
    8989            _settings.PeerStatusChanged(P2PPeerSettings.PeerStatus.Connecting);
    90             P2PManager.Instance.P2PBase.OnP2PMessageReceived += P2PBaseOnP2PMessageReceived;
    91 
    92             if (P2PManager.Instance.IsP2PConnected())
     90            P2PManager.P2PBase.OnP2PMessageReceived += P2PBaseOnP2PMessageReceived;
     91
     92            if (P2PManager.IsConnected)
    9393            {
    9494                GuiLogMessage("P2P connected.", NotificationLevel.Info);
    9595                _settings.PeerStatusChanged(P2PPeerSettings.PeerStatus.Online);
    9696            }
    97             else if (!P2PManager.Instance.IsP2PConnected() && P2PManager.Instance.IsP2PConnecting)
     97            else if (!P2PManager.IsConnected && P2PManager.IsConnecting)
    9898            {
    9999                HandleAlreadyConnecting();
     
    117117        private void HandleAlreadyConnecting()
    118118        {
    119             P2PManager.OnP2PConnectionStateChangeOccurred += HandleConnectionStateChange;
     119            P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred += HandleConnectionStateChange;
    120120            _connectResetEvent = new AutoResetEvent(false);
    121121            _connectResetEvent.WaitOne();
    122122
    123             if (P2PManager.Instance.IsP2PConnected())
     123            if (P2PManager.IsConnected)
    124124            {
    125125                GuiLogMessage("P2P connected.", NotificationLevel.Info);
     
    137137        private void HandleAutoconnect()
    138138        {
    139             P2PManager.OnP2PConnectionStateChangeOccurred += HandleConnectionStateChange;
     139            P2PManager.ConnectionManager.OnP2PConnectionStateChangeOccurred += HandleConnectionStateChange;
    140140            _connectResetEvent = new AutoResetEvent(false);
    141141
    142             new ConnectionWorker(P2PManager.Instance.P2PBase).Start();
     142            P2PManager.Connect();
    143143
    144144            _connectResetEvent.WaitOne();
    145145
    146             if (P2PManager.Instance.IsP2PConnected())
     146            if (P2PManager.IsConnected)
    147147            {
    148148                GuiLogMessage("P2P network was connected due to plugin setting.",
     
    166166        public void StopPeer()
    167167        {
    168             P2PManager.Instance.P2PBase.OnP2PMessageReceived -= P2PBaseOnP2PMessageReceived;
     168            P2PManager.P2PBase.OnP2PMessageReceived -= P2PBaseOnP2PMessageReceived;
    169169            GuiLogMessage("Removed event registration, but peer cannot be stopped, it is running in CrypTool!", NotificationLevel.Info);
    170170        }
     
    271271            _systemJoined = new AutoResetEvent(false);
    272272
    273             P2PManager.Instance.P2PBase.OnSystemJoined += P2PBaseOnSystemJoined;
    274             P2PManager.Instance.OnPeerMessageReceived += P2PPeerOnPeerMessageReceived;
     273            P2PManager.P2PBase.OnSystemJoined += P2PBaseOnSystemJoined;
     274            P2PManager.P2PBase.OnP2PMessageReceived += P2PPeerOnPeerMessageReceived;
    275275            OnStatusChanged += P2PPeerMaster_OnStatusChanged;
    276276        }
     
    333333        public bool DHTstore(string sKey, byte[] byteValue)
    334334        {
    335             return P2PManager.Instance.IsP2PConnected() && P2PManager.Store(sKey, byteValue);
     335            return P2PManager.IsConnected && P2PManager.Store(sKey, byteValue);
    336336        }
    337337
    338338        public bool DHTstore(string sKey, string sValue)
    339339        {
    340             return P2PManager.Instance.IsP2PConnected() && P2PManager.Store(sKey, sValue);
     340            return P2PManager.IsConnected && P2PManager.Store(sKey, sValue);
    341341        }
    342342
    343343        public byte[] DHTload(string sKey)
    344344        {
    345             return P2PManager.Instance.IsP2PConnected() ? P2PManager.Retrieve(sKey) : null;
     345            return P2PManager.IsConnected ? P2PManager.Retrieve(sKey) : null;
    346346        }
    347347
    348348        public bool DHTremove(string sKey)
    349349        {
    350             return P2PManager.Instance.IsP2PConnected() && P2PManager.Remove(sKey);
     350            return P2PManager.IsConnected && P2PManager.Remove(sKey);
    351351        }
    352352
     
    362362                if (_peerId == null)
    363363                {
    364                     _peerId = P2PManager.Instance.P2PBase.GetPeerId(out _sPeerName);
     364                    _peerId = P2PManager.P2PBase.GetPeerId(out _sPeerName);
    365365                }
    366366                sPeerName = _sPeerName;
     
    374374        public PeerId GetPeerID(byte[] byteId)
    375375        {
    376             return P2PManager.Instance.P2PBase.GetPeerId(byteId);
     376            return P2PManager.P2PBase.GetPeerId(byteId);
    377377        }
    378378
     
    480480        private static bool SystemJoinedCompletely()
    481481        {
    482             return P2PManager.Instance.IsP2PConnected() && !P2PManager.Instance.IsP2PConnecting;
     482            return P2PManager.IsConnected && !P2PManager.IsConnecting;
    483483        }
    484484
     
    486486        {
    487487            if (SystemJoinedCompletely())
    488                 P2PManager.Instance.P2PBase.SendToPeer(data, destinationAddress.ToByteArray());
     488                P2PManager.P2PBase.SendToPeer(data, destinationAddress.ToByteArray());
    489489        }
    490490
Note: See TracChangeset for help on using the changeset viewer.