/// <summary>
 /// Constructor: Initialises/Connects channel and retreives current hashtable state.
 /// </summary>
 /// <param name="channel">The Channel to be used for sharing updates.</param>
 /// <param name="channelName">Name of channel to connect to.</param>
 /// <param name="listener">Object that will receive notification of updates.</param>
 public DistributedHashtable(Channel channel,string channelName, Listener listener)
     : base()
 {
     this.channel = channel;
     this.ad = new PullPushAdapter(channel, this);
     this.listener=listener;
     Console.WriteLine("About to connect to channel -->" + DateTime.Now.ToLongTimeString());
     channel.connect(channelName);
     Console.WriteLine("Connected -->" + DateTime.Now.ToLongTimeString());
     ad.start();
     if(channel.getView().size()>1)
         getState();
 }
 /// <summary>
 /// Constructor: Initialises/Connects channel and retreives current hashtable state.
 /// </summary>
 /// <param name="channel">The Channel to be used for sharing updates.</param>
 /// <param name="channelName">Name of channel to connect to.</param>
 /// <param name="listener">Object that will receive notification of updates.</param>
 public DistributedHashtable(Channel channel, string channelName, Listener listener) : base()
 {
     this.channel  = channel;
     this.ad       = new PullPushAdapter(channel, this);
     this.listener = listener;
     Console.WriteLine("About to connect to channel -->" + DateTime.Now.ToLongTimeString());
     channel.connect(channelName);
     Console.WriteLine("Connected -->" + DateTime.Now.ToLongTimeString());
     ad.start();
     if (channel.getView().size() > 1)
     {
         getState();
     }
 }
Beispiel #3
0
 private void disconnectChannel()
 {
     if(chan==null)
     {
         if(chkCausal.Checked)
             props += ":CAUSAL";
         chan = new GroupChannel(props);
         chan.setChannelListener(this);
         ad = new PullPushAdapter(chan, this, this);
     }
     if(!chan.isConnected())
     {
         if(String.Compare(txtGroupName.Text.Trim(),"")!=0)
         {
             chan.connect(txtGroupName.Text.Trim());
             ad.start();
         }
         else
         {
             MessageBox.Show(this,"text","caption",MessageBoxButtons.OK);
             return;
         }
         btnConnect.Text = "Disconnect";
         txtGroupName.Enabled = false;
         txtToSend.Enabled = true;
         txtHandle.Enabled = true;
         txtToSend.Text = "";
         btnSendMessage.Enabled = true;
         lstMembers.Enabled = true;
         txtMsgsReceived.Enabled = true;
         txtMsgsReceived.Text = "";
     }
     else
     {
         ad.stop();
         chan.disconnect();
         btnConnect.Text = "Connect";
         txtGroupName.Enabled = true;
         txtToSend.Enabled = false;
         btnSendMessage.Enabled = false;
         txtHandle.Enabled = false;
         lstMembers.Enabled = false;
         txtMsgsReceived.Enabled = false;
     }
 }