Example #1
0
        private void fncHostQAService(object lstParams)
        {
            try
            {
                List <object> lstTempObj = (List <object>)lstParams;
                strUri = lstTempObj[1].ToString();

                if ((VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.NodeWithNetP2P || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.BootStrap || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.SuperNode)
                {
                    NetPeerClient npcQA = new NetPeerClient();
                    ((clsNetTcpQA)objNetTcpQA).EntsvcP2PJoin          += new clsNetTcpQA.DelsvcP2Pjoin(ctlQA_EntsvcP2PJoin);
                    ((clsNetTcpQA)objNetTcpQA).EntsvcP2PAskQuestion   += new clsNetTcpQA.DelsvcP2PAskQuestion(ctlQA_EntsvcP2PAskQuestion);
                    ((clsNetTcpQA)objNetTcpQA).entsvcP2PReplyQuestion += new clsNetTcpQA.DelsvcP2PReplyQuestion(ctlQA_entsvcP2PReplyQuestion);
                    NetP2PChannel = (INetTcpQAChannel)npcQA.OpenClient <INetTcpQAChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[1], ref objNetTcpQA);
                    while (Counter < 20)
                    {
                        try
                        {
                            NetP2PChannel.svcP2PJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                            Counter = 20;
                        }
                        catch
                        {
                            Counter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                }
                else
                {
                    //DummyClient dc = new DummyClient();
                    //string httpuri = dc.QAClient(idCounter, strUri, VMukti.Global.VMuktiGlobal.strSuperNodeIP);

                    BasicHttpClient BasicQAClient = new BasicHttpClient();
                    HttpChannel = (IHttpQA)BasicQAClient.OpenClient <IHttpQA>(strUri);

                    while (tempcounter < 20)
                    {
                        try
                        {
                            HttpChannel.svcHttpJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);;
                            tempcounter = 20;
                        }
                        catch
                        {
                            tempcounter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    dt.Interval = TimeSpan.FromSeconds(2);
                    dt.Tick    += new EventHandler(dt_Tick);
                    dt.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("hostQAservice " + ex.Message);
                if (ex.InnerException != null)
                {
                    MessageBox.Show("hostQAservice" + ex.InnerException.Message);
                }
            }
        }
Example #2
0
        private void fncHostQAService(object lstParams)
        {
            try
            {
                List<object> lstTempObj = (List<object>)lstParams;
                strUri = lstTempObj[1].ToString();

                if ((VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.NodeWithNetP2P || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.BootStrap || (VMuktiAPI.PeerType)lstTempObj[0] == VMuktiAPI.PeerType.SuperNode)
                {
                    NetPeerClient npcQA = new NetPeerClient();
                    ((clsNetTcpQA)objNetTcpQA).EntsvcP2PJoin += new clsNetTcpQA.DelsvcP2Pjoin(ctlQA_EntsvcP2PJoin);
                    ((clsNetTcpQA)objNetTcpQA).EntsvcP2PAskQuestion += new clsNetTcpQA.DelsvcP2PAskQuestion(ctlQA_EntsvcP2PAskQuestion);
                    ((clsNetTcpQA)objNetTcpQA).entsvcP2PReplyQuestion += new clsNetTcpQA.DelsvcP2PReplyQuestion(ctlQA_entsvcP2PReplyQuestion);
                    NetP2PChannel = (INetTcpQAChannel)npcQA.OpenClient<INetTcpQAChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[1], ref objNetTcpQA);
                    while (Counter < 20)
                    {
                        try
                        {
                            NetP2PChannel.svcP2PJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                            Counter = 20;
                        }
                        catch
                        {
                            Counter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                }
                else
                {
                    //DummyClient dc = new DummyClient();
                    //string httpuri = dc.QAClient(idCounter, strUri, VMukti.Global.VMuktiGlobal.strSuperNodeIP);

                    BasicHttpClient BasicQAClient = new BasicHttpClient();
                    HttpChannel = (IHttpQA)BasicQAClient.OpenClient<IHttpQA>(strUri);

                    while (tempcounter < 20)
                    {
                        try
                        {
                            HttpChannel.svcHttpJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);;
                            tempcounter = 20;
                        }
                        catch
                        {
                            tempcounter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    dt.Interval = TimeSpan.FromSeconds(2);
                    dt.Tick += new EventHandler(dt_Tick);
                    dt.Start();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("hostQAservice " + ex.Message);
                if (ex.InnerException != null)
                {
                    MessageBox.Show("hostQAservice" + ex.InnerException.Message);
                }
            }
        }