Example #1
0
 void btnSay_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (strRole == "Host")
         {
             if (lstQuestionHost.SelectedItems.Count == 1)
             {
                 rtbAnswer.AppendText(Char.ConvertFromUtf32(13) + "Question:" + ((ListBoxItem)lstQuestionHost.SelectedItem).Content.ToString().Split(':')[1]);
                 rtbAnswer.AppendText(Char.ConvertFromUtf32(13) + "Answer:" + txtQuestion.Text);
                 if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap)
                 {
                     if (NetP2PChannel != null)
                     {
                         NetP2PChannel.svcP2PReplyQuestion(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, lstQuestionHost.SelectedItem.ToString().Split(':')[2], txtQuestion.Text, "Guest", sBuddyList);
                     }
                 }
                 else
                 {
                     if (HttpChannel != null)
                     {
                         HttpChannel.svcHttpReplyQuestion(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, lstQuestionHost.SelectedItem.ToString().Split(':')[2], txtQuestion.Text, "Guest", sBuddyList);
                     }
                 }
                 lstQuestionHost.Items.Remove(lstQuestionHost.SelectedItem);
                 txtQuestion.Text = "";
             }
             else
             {
                 MessageBox.Show("Select One Question");
             }
         }
         else if (strRole == "Guest")
         {
             if (txtQuestion.Text != "")
             {
                 ListBoxItem objListBoxItem = new ListBoxItem();
                 objListBoxItem.Content = txtQuestion.Text;
                 lstQuestionGuest.Items.Add(objListBoxItem);
                 if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.NodeWithNetP2P || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == VMuktiAPI.PeerType.BootStrap)
                 {
                     if (NetP2PChannel != null)
                     {
                         NetP2PChannel.svcP2PAskQuestion(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, txtQuestion.Text, "Host");
                     }
                 }
                 else
                 {
                     if (HttpChannel != null)
                     {
                         HttpChannel.svcHttpAskQuestion(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, txtQuestion.Text, "Host");
                     }
                 }
                 txtQuestion.Text = "";
             }
         }
     }
     catch (Exception exp)
     {
         MessageBox.Show("btnSay_Click" + exp.Message);
     }
 }