private void CloseConsoleClient()
 {
     try
     {
         if (objChannel != null && objChannel.State == System.ServiceModel.CommunicationState.Opened)
         {
             objChannel.Close();
             npc.CloseClient<INetP2PConsoleChannel>();
             objChannel = null;
             npc = null;
         }
     }
     catch (Exception ex)
     {
         VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "CloseConsoleClient()", "pgHome.xaml.cs");
     }
 }
        void LogOut()
        {
            try
            {
                //ClsException.WriteToLogFile("LogOut  -- pgHome.xaml.cs  " + DateTime.Now);
                
                
                if (!isEventOccured)
                {
                    isEventOccured = true;

                    try
                    {
                    //    foreach (KeyValuePair<int, int> kvp in VMuktiAPI.VMuktiInfo.CurrentPeer.ConferenceUser)
                    //    {
                    //        if (kvp.Value == VMuktiAPI.VMuktiInfo.CurrentPeer.ID)
                    //        {
                    //            //update this entry from database UPDATE ConferenceUsers set Started='true' where ConfID='3' and UserID='3'
                    //            ClsConferenceUsers objUpdateStarted = new ClsConferenceUsers();
                    //            objUpdateStarted.UpdateStarted(kvp.Key, kvp.Value, false);
                    //        }
                    //    }
                        //VMuktiAPI.VMuktiInfo.CurrentPeer.ConferenceUser.Clear();

                        for (int cnt = 0; cnt <objVMuktiGrid.pageControl.Items.Count; cnt++)
                        {
                            if (((VMuktiGrid.ctlPage.TabItem)objVMuktiGrid.pageControl.Items[cnt]).ConfID != 0)
                            {
                                ((VMuktiGrid.ctlPage.TabItem)objVMuktiGrid.pageControl.Items[cnt]).ClosePage();
                            }
                        }

                        VMuktiAPI.VMuktiInfo.CurrentPeer.ConferenceUser.Clear();
                    }
                    catch (Exception ex)
                    {
                        VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "LogOut()--MeetingSchedular", "pgHome.xaml.cs");
                    }


                    //ClsException.WriteToLogFile("LogOut  -- pgHome.xaml.cs  " + DateTime.Now);
                    VMuktiAPI.VMuktiHelper.CallEvent("LogoutBuddyList", this, new VMuktiAPI.VMuktiEventArgs());
                    if (App.chHttpSuperNodeService != null)
                    {
                        App.chHttpSuperNodeService.svcUnjoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                        App.objHttpSuperNode.CloseClient<IHttpSuperNodeService>();
                    }
                    if (clientHttpChannelBandwidth != null)
                    {
                        clientHttpChannelBandwidth = null;
                    }

                    bool isSuperNode = false;
                    if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode)
                    {
                        isSuperNode = true;
                    }


                    if (App.chHttpBootStrapService != null)
                    {

                        App.chHttpBootStrapService.svcHttpBSUnJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName, VMuktiAPI.VMuktiInfo.CurrentPeer.CurrentMachineIP, isSuperNode);

                    }



                    if (VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.SuperNode || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.BootStrap || VMuktiAPI.VMuktiInfo.CurrentPeer.CurrPeerType == PeerType.NodeWithNetP2P)
                    {
                        if (objChannel != null && objChannel.State == System.ServiceModel.CommunicationState.Opened)
                        {
                            objChannel.Close();
                            npc.CloseClient<INetP2PConsoleChannel>();
                            objChannel = null;
                            npc = null;
                        }

                        if (App.chNetP2PSuperNodeChannel != null && App.chNetP2PSuperNodeChannel.State == System.ServiceModel.CommunicationState.Opened)
                        {
                            App.chNetP2PSuperNodeChannel.Close();
                            npcP2PSuperNode.CloseClient<INetP2PSuperNodeChannel>();
                            App.objNetP2PSuperNode = null;
                            npcP2PSuperNode = null;
                        }
                    }

                    if (dispTmrCheckStatus != null)
                    {
                        dispTmrCheckStatus.Stop();
                    }

                    //VMuktiAPI.VMuktiInfo.CurrentPeer.ID = int.MinValue;

                    VMuktiAPI.VMuktiHelper.CallEvent("SignOut", null, null);
                   
                }

                btnBList.Visibility = Visibility.Collapsed;

                btnSettings.Visibility = Visibility.Collapsed;
                btnLogin.Visibility = Visibility.Collapsed;

                objBuddies.Visibility = Visibility.Collapsed;

                btnConsole.Visibility = Visibility.Collapsed;
                tblkUserName.Text = String.Empty;
                tblkUserName.Visibility = Visibility.Collapsed;

                btnRecord.Visibility = Visibility.Collapsed;
                VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName = "";

                #region UICHANGE

                // SkinPopUp.Visibility = Visibility.Collapsed;
                //ThemepopUp.Visibility = Visibility.Collapsed;
                // BackgroundImagePopUp.Visibility = Visibility.Collapsed;

                #endregion
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "LogOut()", "pgHome.xaml.cs");

            }

        }
        private void OpenConsoleClient()
        {
            try
            {
                npc = new NetPeerClient();

                ClsNetP2PConsoleDelegates objP2PConsoleDel = new ClsNetP2PConsoleDelegates();

                objP2PConsoleDel.EntsvcNetP2PConsoleJoin += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleJoin(pgHome_EntsvcNetP2PConsoleJoin);
                objP2PConsoleDel.EntsvcNetP2PConsoleSendMsg += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleSendMsg(pgHome_EntsvcNetP2PConsoleSendMsg);
                objP2PConsoleDel.EntsvcNetP2PConsoleGetLog += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleGetLog(pgHome_EntsvcNetP2PConsoleGetLog);
                objP2PConsoleDel.EntsvcNetP2PConsoleSendLog += new ClsNetP2PConsoleDelegates.DelsvcNetP2pConsoleSendLog(pgHome_EntsvcNetP2PConsoleSendLog);
                objP2PConsoleDel.EntsvcNetP2PConsoleUnJoin += new ClsNetP2PConsoleDelegates.DelsvcNetP2PConsoleUnJoin(pgHome_EntsvcNetP2PConsoleUnJoin);

                objNetTcpConsole = objP2PConsoleDel;

                objChannel = (INetP2PConsoleChannel)npc.OpenClient<INetP2PConsoleChannel>("net.tcp://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":8080/NetP2PConsole", "ConsoleMesh", ref objNetTcpConsole);
                objChannel.svcNetP2ConsoleJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "openConsoleClient()", "pgHome.xaml.cs");
            }

        }