Ignore:
Timestamp:
Nov 17, 2009, 1:05:15 PM (12 years ago)
Author:
arnold
Message:

Buggy P2P version

Location:
trunk/CrypPlugins/PeerToPeerPublisher
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerPublisher/P2PPublisher.cs

    r836 r862  
    2727/*
    2828 * TODO:
    29  * - independent reverse counter per subscriber / timestamp dict (Key = SubID, Value = TimeStamp | SecondChanceStep)
    3029 * - FUTURE: dual data management of subscriber list (on local peer and in DHT)
    3130 */
     
    4039    public class P2PPublisher : IInput
    4140    {
    42         #region PrivVariables (Lists, Timer, etc)
    43 
    44         private string sDHTSettingsPostfix = "Settings";
    45 
    4641        private P2PPublisherSettings settings;
    4742        private IP2PControl p2pMaster;
    48         /*
    49         private List<byte[]> lstSubscribers = new List<byte[]>();
    50         private List<byte[]> lstWaitingForPong = new List<byte[]>();
    51         private List<byte[]> lstAliveArrived = new List<byte[]>();
    52         */
    53         private SubscriberInfo subManagement;
    54         private Timer timerWaitingForAliveMsg;
    55         private long aliveMessageInterval;
     43        private P2PPublisherBase p2pPublisher;
     44
     45        public P2PPublisher()
     46        {
     47            this.settings = new P2PPublisherSettings(this);
     48            this.settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged);
     49            this.settings.TaskPaneAttributeChanged += new TaskPaneAttributeChangedHandler(settings_TaskPaneAttributeChanged);
     50        }
     51
     52        #region SettingEvents
     53
     54        private void settings_TaskPaneAttributeChanged(ISettings settings, TaskPaneAttributeChangedEventArgs args)
     55        {
     56            //throw new NotImplementedException();
     57        }
     58
     59        private void settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
     60        {
     61            // storing settings for subscribers in the DHT, so they can load them there
     62            if (e.PropertyName == "SendAliveMessageInterval")
     63            {
     64                this.p2pMaster.DHTstore(settings.TopicName + "Settings",
     65                    System.BitConverter.GetBytes(this.settings.SendAliveMessageInterval));
     66            }
     67            // if TaskName has changed, clear the Lists, because the Subscribers must reconfirm registering
     68            if (e.PropertyName == "TopicName")
     69            {
     70                GuiLogMessage("Topic Name has changed, so all subscribers must reconfirm registering!", NotificationLevel.Warning);
     71                // stop active publisher and tell all subscribers that topic name isn't valid anymore
     72                this.p2pPublisher.Stop(PubSubMessageType.Unregister);
     73                // start publisher for the changed topic
     74                this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     75            }
     76            if (e.PropertyName == "BtnUnregister")
     77            {
     78                this.p2pPublisher.Stop(PubSubMessageType.Unregister);
     79                GuiLogMessage("Unregister button pressed, Publisher has stopped!", NotificationLevel.Info);
     80            }
     81            if (e.PropertyName == "BtnRegister")
     82            {
     83                this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     84                GuiLogMessage("Register button pressed, Publisher has been started!", NotificationLevel.Info);
     85            }
     86            if (e.PropertyName == "BtnSolutionFound")
     87            {
     88                this.p2pPublisher.Stop(PubSubMessageType.Solution);
     89                GuiLogMessage("TEST: Emulate Solution-Found-message", NotificationLevel.Info);
     90            }
     91        }
    5692
    5793        #endregion
     
    124160        #region Standard PlugIn-Functionality
    125161
    126         public P2PPublisher()
    127         {
    128             this.settings = new P2PPublisherSettings(this);
    129             this.settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged);
    130         }
    131 
    132         void settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
    133         {
    134             // storing settings for subscribers in the DHT, so they can load them there
    135             if (e.PropertyName == "SendAliveMessageInterval")
    136             {
    137                 this.p2pMaster.DHTstore(settings.TaskName + this.sDHTSettingsPostfix,
    138                     System.BitConverter.GetBytes(this.settings.SendAliveMessageInterval));
    139             }
    140             // if TaskName has changed, clear the Lists, because the Subscribers must reconfirm registering
    141             if (e.PropertyName == "TaskName")
    142             {
    143                 /*
    144                 this.lstSubscribers.Clear();
    145                 this.lstAliveArrived.Clear();
    146                 this.lstWaitingForPong.Clear();
    147                 */
    148                 GuiLogMessage("Taskname has changed, so all subscribers must reconfirm registering!",NotificationLevel.Warning);
    149             }
    150         }
    151 
    152162        public ISettings Settings
    153163        {
     
    168178        public void PreExecution()
    169179        {
    170             aliveMessageInterval = (long)this.settings.SendAliveMessageInterval * 1000;
    171             this.subManagement = new SubscriberInfo(aliveMessageInterval);
    172             this.subManagement.OnSubscriberRemoved += new SubscriberInfo.SubscriberRemoved(subManagement_OnSubscriberRemoved);
    173         }
    174 
    175         // Execute-Method is below this region
    176 
    177         public void PostExecution()
    178         {
    179             //throw new NotImplementedException();
    180         }
    181 
    182         public void Pause()
    183         {
    184             //throw new NotImplementedException();
    185         }
    186 
    187         public void Stop()
    188         {
    189             if (this.timerWaitingForAliveMsg != null)
    190             {
    191                 this.timerWaitingForAliveMsg.Dispose();
    192                 this.timerWaitingForAliveMsg = null;
    193             }
    194         }
    195 
    196         public void Initialize()
    197         {
    198         }
    199 
    200         public void Dispose()
    201         {
    202         }
    203 
    204         #endregion
    205 
    206         public void Execute()
    207         {
    208180            // if no P2P Slave PlugIn is connected with this PlugIn --> No execution!
    209181            if (P2PMaster == null)
     
    212184                return;
    213185            }
    214             if (this.settings.TaskName != null)
    215             {
    216                 string sActualPeerName;
    217 
    218                 // publish own PeerID to the DHT Entry with the key "TaskName", so every subscriber
    219                 // can retrieve the name and send a register-message to the publisher
    220                 byte[] bytePeerId = P2PMaster.GetPeerID(out sActualPeerName);
    221 
    222                 sActualPeerName = P2PMaster.ConvertPeerId(bytePeerId);
    223 
    224                 // Question: Why casting to String isn't possible?
    225                 P2PMaster.DHTstore(this.settings.TaskName, bytePeerId);
    226                 P2PMaster.DHTstore(this.settings.TaskName + this.sDHTSettingsPostfix,
    227                     System.BitConverter.GetBytes(aliveMessageInterval));
    228 
    229                 GuiLogMessage("Peer ID '" + P2PMaster.ConvertPeerId(bytePeerId) + "' is published to DHT -Entry-Key '" + this.settings.TaskName + "'", NotificationLevel.Info);
    230             }
    231             else
     186
     187            if (this.p2pPublisher == null)
     188            {
     189                this.p2pPublisher = new P2PPublisherBase(this.P2PMaster);
     190                this.p2pPublisher.OnGuiMessage += new P2PPublisherBase.GuiMessage(p2pPublisher_OnGuiMessage);
     191                this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     192            }
     193        }
     194
     195        public void Execute()
     196        {
     197            if (this.settings == null && this.settings.TopicName == null)
    232198            {
    233199                GuiLogMessage("There is no input and/or empty Settings. Storing isn't possible.", NotificationLevel.Error);
    234200                return;
    235201            }
     202
    236203            if (this.Inputvalue != null)
    237204            {
    238                 PublishText(this.Inputvalue);
    239             }
    240         }
    241 
    242         private void PublishText(string sText)
    243         {
    244             Dictionary<byte[], DateTime> lstSubscribers = this.subManagement.GetAllSubscribers();
    245             foreach (byte[] byteSubscriber in lstSubscribers.Keys)
    246             {
    247                 this.P2PMaster.SendToPeer(sText, byteSubscriber);
    248             }
    249         }
    250 
    251         private void p2pMaster_OnPeerReceivedMsg(byte[] byteSourceAddr, string sData)
    252         {
    253             if (sData.Trim() == "regi")
    254             {
    255                 if (this.subManagement.Add(byteSourceAddr))
    256                     GuiLogMessage("REGISTERED: Peer with ID " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    257                 else
    258                     GuiLogMessage("ALREADY REGISTERED peer with ID " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    259             }
    260             else
    261             {
    262                 if (this.subManagement.Update(byteSourceAddr))
    263                     GuiLogMessage("RECEIVED: " + sData.Trim() + " Message from " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    264                 else
    265                     GuiLogMessage("UPDATE FAILED for " + P2PMaster.ConvertPeerId(byteSourceAddr) + " because it hasn't registered first.", NotificationLevel.Info);
    266                 if (sData.Trim() == "ping")
    267                     this.P2PMaster.SendToPeer("pong", byteSourceAddr);
    268             }
    269             if(timerWaitingForAliveMsg == null)
    270                 timerWaitingForAliveMsg = new Timer(OnWaitingForAliveMsg, null, this.settings.SendAliveMessageInterval * 1000,
    271                     this.settings.SendAliveMessageInterval * 1000);
    272         }
    273 
    274         private void OnWaitingForAliveMsg(object state)
    275         {
    276             List<byte[]> lstOutdatedSubscribers = this.subManagement.CheckVitality();
    277             foreach (byte[] outdatedSubscriber in lstOutdatedSubscribers)
    278             {
    279                 P2PMaster.SendToPeer("ping", outdatedSubscriber);
    280                 GuiLogMessage("PING outdated peer " + P2PMaster.ConvertPeerId(outdatedSubscriber), NotificationLevel.Info);
    281             }
    282         }
    283 
    284         private void subManagement_OnSubscriberRemoved(byte[] byPeerId)
    285         {
    286             GuiLogMessage("REMOVED subscriber " + P2PMaster.ConvertPeerId(byPeerId), NotificationLevel.Info);
    287         }
    288 
    289         /*OLD SOLUTION - WORKS, BUT NOT THE BEST WAY...*/
    290         /*
    291         void p2pMaster_OnPeerReceivedMsg(byte[] byteSourceAddr, string sData)
    292         {
    293             if (sData.Trim() == "regi")
    294             {
    295                 if (!lstSubscribers.Contains(byteSourceAddr))
    296                 {
    297                     lstSubscribers.Add(byteSourceAddr);
    298                     GuiLogMessage("REGISTERED: Peer with ID " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    299                     StartWaitingTimer();
    300                 }
    301             }
    302             if (sData.Trim() == "aliv")
    303             {
    304                 if (!lstAliveArrived.Contains(byteSourceAddr))
    305                 {
    306                     lstAliveArrived.Add(byteSourceAddr);
    307                     GuiLogMessage("RECEIVED: Alive Message from " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    308                     // if Alive Msg arrived to late, the subscriber was removed from list
    309                     // of active subscribers. So we must add him again.
    310                     if (!lstSubscribers.Contains(byteSourceAddr))
    311                         lstSubscribers.Add(byteSourceAddr);
    312                     StartWaitingTimer();
    313                 }
    314             }
    315             if (sData.Trim() == "pong")
    316             {
    317                 GuiLogMessage("RECEIVED: Pong Message from " + P2PMaster.ConvertPeerId(byteSourceAddr), NotificationLevel.Info);
    318                 if (lstWaitingForPong.Contains(byteSourceAddr))
    319                     lstWaitingForPong.Remove(byteSourceAddr);
    320             }
    321         }
    322 
    323         private void StartWaitingTimer()
    324         {
    325             // check every 30 seconds if the subscribers are still alive
    326             // Timer gets started not until retrieving the first register message from a Subscriber
    327             if (timerWaitingForAliveMsg == null)
    328                 timerWaitingForAliveMsg = new Timer(OnWaitingForAliveMsg, null, 30000, 30000);
    329         }
    330 
    331         private void OnWaitingForAliveMsg(object state)
    332         {
    333             GuiLogMessage("Checking vitality of Subscribers", NotificationLevel.Info);
    334             for (int i = 0; i < this.lstSubscribers.Count; i++)
    335             {
    336                 if (!this.lstAliveArrived.Contains(this.lstSubscribers[i]))
    337                 {
    338                     // only if Subscriber had not send a Alive message
    339                     // remove him from the subscriber list
    340                     GuiLogMessage("DEAD: Subscriber " + P2PMaster.ConvertPeerId(this.lstSubscribers[i]) + " is removed from SubList!", NotificationLevel.Info);
    341                     this.lstSubscribers.Remove(this.lstSubscribers[i]);
    342                 }
    343                 else
    344                 {
    345                     this.lstAliveArrived.Remove(this.lstSubscribers[i]);
    346                 }
    347             }
    348             // if there are no more subscribers, stop Timer of
    349             // waiting for alive messages
    350             if (this.lstSubscribers.Count == 0)
    351             {
    352                 timerWaitingForAliveMsg.Dispose();
    353                 return;
    354             }
    355         }
    356         */
     205                this.p2pPublisher.Publish(this.Inputvalue);
     206            }
     207        }
     208
     209        public void PostExecution()
     210        {
     211            //throw new NotImplementedException();
     212        }
     213
     214        public void Pause()
     215        {
     216            //throw new NotImplementedException();
     217        }
     218
     219        public void Stop()
     220        {
     221            if(this.p2pPublisher != null)
     222                this.p2pPublisher.Stop(PubSubMessageType.Unregister);
     223        }
     224
     225        public void Initialize()
     226        {
     227        }
     228
     229        public void Dispose()
     230        {
     231        }
     232
     233        #endregion
     234
     235        private void p2pMaster_OnPeerReceivedMsg(string sSourceAddr, string sData)
     236        {
     237            //this.p2pPublisher.MessageReceived(sSourceAddr, sData);
     238        }
     239
     240        private void p2pPublisher_OnGuiMessage(string sData, NotificationLevel notificationLevel)
     241        {
     242            GuiLogMessage(sData, notificationLevel);
     243        }
    357244
    358245        #region INotifyPropertyChanged Members
     
    378265
    379266        #endregion
     267
     268        //#region Publisher methods
     269
     270        //private string topic = String.Empty;
     271        //private string sDHTSettingsPostfix = "Settings";
     272        //private SubscriberManagement subManagement;
     273        //private Timer timerWaitingForAliveMsg;
     274        //private string sPeerName;
     275        //private long aliveMessageInterval;
     276
     277        //private bool StartPublisher(string sTopic, long aliveMessageInterval)
     278        //{
     279        //    this.topic = sTopic;
     280        //    aliveMessageInterval = aliveMessageInterval * 1000;
     281        //    this.subManagement = new SubscriberManagement(aliveMessageInterval);
     282        //    this.subManagement.OnSubscriberRemoved += new SubscriberManagement.SubscriberRemoved(subManagement_OnSubscriberRemoved);
     283
     284        //    string sActualPeerName;
     285
     286        //    // publish own PeerID to the DHT Entry with the key "TaskName", so every subscriber
     287        //    // can retrieve the name and send a register-message to the publisher
     288        //    string sPeerId = P2PMaster.GetPeerID(out sPeerName);
     289        //    //byte[] bytePeerId = P2PMaster.GetPeerID(out sActualPeerName);
     290
     291        //    sActualPeerName = sPeerId;
     292
     293        //    // before storing the publishers ID in the DHT, proof whether there already exist an entry
     294        //    byte[] byRead = P2PMaster.DHTload(sTopic);
     295        //    string sRead;
     296        //    // if byRead is not null, the DHT entry was already written
     297        //    if (byRead != null)
     298        //    {
     299        //        sRead = UTF8Encoding.UTF8.GetString(byRead);
     300        //        // if sRead equals sPeerId this Publisher with the same topic had written
     301        //        // this entry - no problem! Otherwise abort Starting the publisher!
     302        //        if (sRead != sPeerId)
     303        //        {
     304        //            GuiLogMessage("Can't store Publisher in the DHT because the Entry was already occupied.", NotificationLevel.Error);
     305        //            return false;
     306        //        }
     307        //    }
     308        //    bool bolTopicStored = P2PMaster.DHTstore(sTopic, sPeerId);
     309        //    bool bolSettingsStored = P2PMaster.DHTstore(sTopic + this.sDHTSettingsPostfix,
     310        //        System.BitConverter.GetBytes(aliveMessageInterval));
     311
     312        //    if (!bolTopicStored || !bolSettingsStored)
     313        //    {
     314        //        GuiLogMessage("Storing Publishers ID or Publishers Settings wasn't possible.", NotificationLevel.Error);
     315        //        return false;
     316        //    }
     317
     318        //    GuiLogMessage("Peer ID '" + sPeerId + "' is published to DHT -Entry-Key '" + this.settings.TopicName + "'", NotificationLevel.Info);
     319        //    return true;
     320        //}
     321
     322        //private void MessageReceived(string sSourceAddr, string sData)
     323        //{
     324        //    PubSubMessageType msgType = this.P2PMaster.GetMsgType(sData);
     325
     326        //    if (msgType != PubSubMessageType.NULL)
     327        //    {
     328        //        switch (msgType)
     329        //        {
     330        //            case PubSubMessageType.Register:
     331        //                if (this.subManagement.Add(sSourceAddr))
     332        //                {
     333        //                    GuiLogMessage("REGISTERED: Peer with ID " + sSourceAddr, NotificationLevel.Info);
     334        //                    this.P2PMaster.SendToPeer(PubSubMessageType.RegisteringAccepted, sSourceAddr);
     335        //                }
     336        //                else
     337        //                {
     338        //                    GuiLogMessage("ALREADY REGISTERED peer with ID " + sSourceAddr, NotificationLevel.Info);
     339        //                }
     340        //                break;
     341        //            case PubSubMessageType.Unregister:
     342        //                if (this.subManagement.Remove(sSourceAddr))
     343        //                    GuiLogMessage("REMOVED subscriber " + sSourceAddr + " because it had sent an unregister message", NotificationLevel.Info);
     344        //                else
     345        //                    GuiLogMessage("ALREADY REMOVED or had not registered anytime. ID " + sSourceAddr, NotificationLevel.Info);
     346        //                break;
     347        //            case PubSubMessageType.Alive:
     348        //            case PubSubMessageType.Pong:
     349        //                if (this.subManagement.Update(sSourceAddr))
     350        //                {
     351        //                    GuiLogMessage("RECEIVED: " + msgType.ToString() + " Message from " + sSourceAddr, NotificationLevel.Info);
     352        //                }
     353        //                else
     354        //                {
     355        //                    GuiLogMessage("UPDATE FAILED for " + sSourceAddr + " because it hasn't registered first. " + msgType.ToString(), NotificationLevel.Info);
     356        //                }
     357        //                break;
     358        //            case PubSubMessageType.Ping:
     359        //                this.P2PMaster.SendToPeer(PubSubMessageType.Pong, sSourceAddr);
     360        //                GuiLogMessage("REPLIED to a ping message from subscriber " + sSourceAddr, NotificationLevel.Info);
     361        //                break;
     362        //            case PubSubMessageType.Solution:
     363        //                // Send solution msg to all subscriber peers and delete subList
     364        //                StopPublisher(msgType);
     365        //                break;
     366        //            default:
     367        //                throw (new NotImplementedException());
     368        //        } // end switch
     369        //        if (timerWaitingForAliveMsg == null)
     370        //            timerWaitingForAliveMsg = new Timer(OnWaitingForAliveMsg, null, this.settings.SendAliveMessageInterval * 1000,
     371        //                this.settings.SendAliveMessageInterval * 1000);
     372        //    }
     373        //    // Received Data aren't PubSubMessageTypes or rather no action-relevant messages
     374        //    else
     375        //    {
     376        //        GuiLogMessage("RECEIVED message from non subscribed peer: " + sData.Trim() + ", ID: " + sSourceAddr, NotificationLevel.Warning);
     377        //    }
     378        //}
     379
     380        //private void Publish(string sText)
     381        //{
     382        //    Dictionary<string, DateTime> lstSubscribers = this.subManagement.GetAllSubscribers();
     383
     384        //    PubSubMessageType msgType = this.P2PMaster.GetMsgType(sText);
     385        //    if (msgType == PubSubMessageType.NULL)
     386        //    {
     387        //        foreach (string sSubscriber in lstSubscribers.Keys)
     388        //        {
     389        //            this.P2PMaster.SendToPeer(sText, sSubscriber);
     390        //        }
     391        //    }
     392        //    else
     393        //    {
     394        //        foreach (string sSubscriber in lstSubscribers.Keys)
     395        //        {
     396        //            this.P2PMaster.SendToPeer(msgType, sSubscriber);
     397        //        }
     398        //    }
     399        //}
     400
     401        ///// <summary>
     402        ///// if peers are outdated (alive message doesn't arrive in the given interval)
     403        ///// ping them to give them a second chance
     404        ///// </summary>
     405        ///// <param name="state"></param>
     406        //private void OnWaitingForAliveMsg(object state)
     407        //{
     408        //    List<string> lstOutdatedSubscribers = this.subManagement.CheckVitality();
     409        //    foreach (string outdatedSubscriber in lstOutdatedSubscribers)
     410        //    {
     411        //        P2PMaster.SendToPeer(PubSubMessageType.Ping, outdatedSubscriber);
     412        //        GuiLogMessage("PING outdated peer " + outdatedSubscriber, NotificationLevel.Info);
     413        //    }
     414        //}
     415
     416        //private void subManagement_OnSubscriberRemoved(string sPeerId)
     417        //{
     418        //    GuiLogMessage("REMOVED subscriber " + sPeerId, NotificationLevel.Info);
     419        //}
     420
     421        //private void StopPublisher(PubSubMessageType msgType)
     422        //{
     423        //    if(this.P2PMaster != null)
     424        //        // send unregister message to all subscribers
     425        //        Publish(((int)msgType).ToString());
     426        //    if (this.P2PMaster != null)
     427        //    {
     428        //        this.P2PMaster.DHTremove(this.topic);
     429        //        this.P2PMaster.DHTremove(this.topic + this.sDHTSettingsPostfix);
     430        //    }
     431        //    if (this.timerWaitingForAliveMsg != null)
     432        //    {
     433        //        this.timerWaitingForAliveMsg.Dispose();
     434        //        this.timerWaitingForAliveMsg = null;
     435        //    }
     436        //}
     437
     438        //#endregion
    380439    }
    381440
  • trunk/CrypPlugins/PeerToPeerPublisher/P2PPublisherSettings.cs

    r836 r862  
    1313    public class P2PPublisherSettings : ISettings
    1414    {
     15        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
    1516        private bool hasChanges = false;
    1617        private P2PPublisher p2pPublisher;
     
    3536        {
    3637            this.p2pPublisher = p2pPublisher;
     38            if (TaskPaneAttributeChanged != null)
     39            {
     40                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnSolutionFound", Visibility.Collapsed)));
     41                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnUnregister", Visibility.Hidden)));
     42                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnRegister", Visibility.Visible)));
     43            }
    3744        }
    3845
    39         private string sTaskName = "NewCompTask";
    40         [TaskPane("Task Name","Choose a name for the computational task",null,0,false,DisplayLevel.Beginner,ControlType.TextBox)]
    41         public string TaskName
     46        private string sTopic = "NewTopic";
     47        [TaskPane("Topic Name","Choose a topic name with which all subscribers can register.",null,0,false,DisplayLevel.Beginner,ControlType.TextBox)]
     48        public string TopicName
    4249        {
    43             get { return this.sTaskName; }
     50            get { return this.sTopic; }
    4451            set
    4552            {
    46                 if (this.sTaskName != value && value != String.Empty && value != null)
     53                if (this.sTopic != value && value != String.Empty && value != null)
    4754                {
    48                     this.sTaskName = value;
     55                    this.sTopic = value;
    4956                    HasChanges = true;
    50                     OnPropertyChanged("TaskName");
     57                    OnPropertyChanged("TopicName");
    5158                }
    5259            }
    5360        }
     61
     62        /* FOR TESTING ISSUES */
     63        [TaskPane("Unregister", "Click here to Unregister the publisher from all registered subscribers!", "Control region", 0, true, DisplayLevel.Beginner, ControlType.Button)]
     64        public void BtnUnregister()
     65        {
     66            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnSolutionFound", Visibility.Collapsed)));
     67            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnUnregister", Visibility.Collapsed)));
     68            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnRegister", Visibility.Visible)));
     69            OnPropertyChanged("BtnUnregister");
     70        }
     71        [TaskPane("Register", "Click here to Register the publisher pro-active with all formely registered subscribers!", "Control region", 1, true, DisplayLevel.Beginner, ControlType.Button)]
     72        public void BtnRegister()
     73        {
     74            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnSolutionFound", Visibility.Visible)));
     75            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnRegister", Visibility.Collapsed)));
     76            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnUnregister", Visibility.Visible)));
     77            OnPropertyChanged("BtnRegister");
     78        }
     79        [TaskPane("Solution found", "TESTING: Emulate solution-found-case!", "Control region", 2, true, DisplayLevel.Beginner, ControlType.Button)]
     80        public void BtnSolutionFound()
     81        {
     82            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnSolutionFound", Visibility.Collapsed)));
     83            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnUnregister", Visibility.Collapsed)));
     84            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("BtnRegister", Visibility.Visible)));
     85            OnPropertyChanged("BtnSolutionFound");
     86        }
     87        /* FOR TESTING ISSUES */
    5488
    5589        private int sendAliveMessageInterval = 20;
  • trunk/CrypPlugins/PeerToPeerPublisher/PeerToPeerPublisher.csproj

    r836 r862  
    5656  <ItemGroup>
    5757    <Compile Include="P2PPublisher.cs" />
     58    <Compile Include="P2PPublisherBase.cs" />
    5859    <Compile Include="P2PPublisherSettings.cs" />
    5960    <Compile Include="Properties\AssemblyInfo.cs" />
    60     <Compile Include="SubscribersInfo.cs" />
     61    <Compile Include="SubscribersManagement.cs" />
    6162  </ItemGroup>
    6263  <ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.