Ejemplo n.º 1
0
        private void FncHostFileSearchService(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 npcFileSearch = new NetPeerClient();
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcJoin+=new clsNetTcpFileSearch.delsvcJoin(FileSearch_EntsvcJoin);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcRequestFile+=new clsNetTcpFileSearch.delsvcRequestFile(FileSearch_EntsvcRequestFile);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcSearchQuery+=new clsNetTcpFileSearch.delsvcSearchQuery(FileSearch_EntsvcSearchQuery);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcSearchResult+=new clsNetTcpFileSearch.delsvcSearchResult(FileSearch_EntsvcSearchResult);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcSendFileBlock+=new clsNetTcpFileSearch.delsvcSendFileBlock(FileSearch_EntsvcSendFileBlock);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcGetUserList += new clsNetTcpFileSearch.delsvcGetUserList(FileSearch_EntsvcGetUserList);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcSetUserList += new clsNetTcpFileSearch.delsvcSetUserList(FileSearch_EntsvcSetUserList);
                    ((clsNetTcpFileSearch)objNetTcpFileSearch).EntsvcUnJoin+=new clsNetTcpFileSearch.delsvcUnJoin(FileSearch_EntsvcUnJoin);
                    NetP2PChannel = (IFileTransferChannel)npcFileSearch.OpenClient<IFileTransferChannel>(strUri, strUri.ToString().Split(':')[2].Split('/')[2], ref objNetTcpFileSearch);
                    //**Opening NetP2p Client for FileSearch.

                    while (Counter < 20)
                    {
                        try
                        {
                            NetP2PChannel.svcJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                            Counter = 20;
                            NetP2PChannel.svcGetUserList(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                        }
                        catch
                        {
                            Counter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                }
                else
                {
                    BasicHttpClient BasicFileSearchClient = new BasicHttpClient();
                    HttpChannel = (IHttpFileSearchChannel)BasicFileSearchClient.OpenClient<IHttpFileSearchChannel>(strUri);
                    //**opening Http client for FileSearch module

                    while (tempcounter < 20)
                    {
                        try
                        {
                            HttpChannel.svcHttpJoin(VMuktiAPI.VMuktiInfo.CurrentPeer.DisplayName);
                            tempcounter = 20;
                        }
                        catch
                        {
                            tempcounter++;
                            System.Threading.Thread.Sleep(1000);
                        }
                    }
                    dt.Interval = TimeSpan.FromSeconds(5);
                    dt.Tick += new EventHandler(dt_Tick);
                    dt.Start();

                    dtGetFileList.Interval = TimeSpan.FromSeconds(10);
                    dtGetFileList.Tick += new EventHandler(dtGetFileList_Tick);
                    dtGetFileList.Start();
                }
            }
            catch (Exception ex)
            {
                VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FncHostFileSearchService", "FileSearch.xaml.cs");
                if (ex.InnerException != null)
                {
                    VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "FncHostFileSearchService", "FileSearch.xaml.cs");

                }
            }
        }