Ignore:
Timestamp:
Jun 24, 2010, 1:15:16 PM (11 years ago)
Author:
Paul Lelgemann
Message:

o Refactoring in CrypP2P
o AES: NullReference in AES-Plugin fixed
o Small fixes in KeySearcher, StorageKeyGenerator uses IV and truncates input data

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypP2P/Internal/ConnectionManager.cs

    r1616 r1698  
    2323    public class ConnectionManager
    2424    {
     25        #region Delegates
     26
    2527        public delegate void P2PConnectionStateChangeEventHandler(object sender, bool newState);
    26         public event P2PConnectionStateChangeEventHandler OnP2PConnectionStateChangeOccurred;
    2728
    28         private readonly object _connectLock = new object();
    29         private readonly P2PBase _p2PBase;
     29        #endregion
    3030
    31         public bool IsConnecting { get; internal set; }
     31        private readonly object connectLock = new object();
     32        private readonly P2PBase p2PBase;
    3233
    3334        public ConnectionManager(P2PBase p2PBase)
    3435        {
    35             _p2PBase = p2PBase;
     36            this.p2PBase = p2PBase;
    3637        }
     38
     39        public bool IsConnecting { get; internal set; }
     40        public event P2PConnectionStateChangeEventHandler OnP2PConnectionStateChangeOccurred;
    3741
    3842        public void Connect()
    3943        {
    40             lock (_connectLock)
     44            lock (connectLock)
    4145            {
    42                 if (_p2PBase.IsConnected || IsConnecting)
     46                if (p2PBase.IsConnected || IsConnecting)
    4347                {
    44                     P2PManager.GuiLogMessage("Cannot connect, already connected or connecting.", NotificationLevel.Warning);
     48                    P2PManager.GuiLogMessage("Cannot connect, already connected or connecting.",
     49                                             NotificationLevel.Warning);
    4550                    return;
    4651                }
     
    5661
    5762            P2PManager.GuiLogMessage("Dispatching connect request with ConnectionWorker.", NotificationLevel.Debug);
    58             new ConnectionWorker(_p2PBase, this).Start();
     63            new ConnectionWorker(p2PBase, this).Start();
    5964        }
    6065
    6166        public void Disconnect()
    6267        {
    63             lock (_connectLock)
     68            lock (connectLock)
    6469            {
    65                 if (!_p2PBase.IsConnected || IsConnecting)
     70                if (!p2PBase.IsConnected || IsConnecting)
    6671                {
    67                     P2PManager.GuiLogMessage("Cannot disconnect, no connection or connection attempt active.", NotificationLevel.Warning);
     72                    P2PManager.GuiLogMessage("Cannot disconnect, no connection or connection attempt active.",
     73                                             NotificationLevel.Warning);
    6874                    return;
    6975                }
    70                
     76
    7177                IsConnecting = true;
    7278            }
    7379
    7480            P2PManager.GuiLogMessage("Dispatching disconnect request with ConnectionWorker.", NotificationLevel.Debug);
    75             new ConnectionWorker(_p2PBase, this).Start();
     81            new ConnectionWorker(p2PBase, this).Start();
    7682        }
    7783
     
    8692            if (String.IsNullOrEmpty(P2PSettings.Default.PeerName))
    8793            {
    88                 P2PManager.GuiLogMessage("Peer-to-peer not fully configured: world name missing.", NotificationLevel.Error);
     94                P2PManager.GuiLogMessage("Peer-to-peer not fully configured: world name missing.",
     95                                         NotificationLevel.Error);
    8996                return false;
    9097            }
     
    97104            if (OnP2PConnectionStateChangeOccurred != null)
    98105            {
    99                 OnP2PConnectionStateChangeOccurred(this, _p2PBase.IsConnected);
     106                OnP2PConnectionStateChangeOccurred(this, p2PBase.IsConnected);
    100107            }
    101108        }
Note: See TracChangeset for help on using the changeset viewer.