コード例 #1
0
        public void RequestMostRecent()
        {
            string mypath     = System.Reflection.Assembly.GetEntryAssembly().Location;
            string finalpath  = mypath.Substring(0, mypath.Length - 10);
            string newpath    = Path.GetFullPath(Path.Combine(finalpath, @"..\..\"));
            string pathToList = newpath + "ListaServers.txt";

            string[] lines = System.IO.File.ReadAllLines(pathToList);
            foreach (string line in lines)
            {
                //port : name
                string[] args = line.Split(':');

                int    server_port = Int32.Parse(args[0]);
                string server_name = args[1];

                try
                {
                    string           url         = "tcp://localhost:" + server_port + "/" + server_name;
                    TcpClientChannel channelnovo = new TcpClientChannel(server_name, null);
                    ChannelServices.RegisterChannel(channelnovo, false);
                    IServerInterface servernovo = (IServerInterface)Activator.GetObject(typeof(IServerInterface), url);
                    if (servernovo.GetNumOps() > numOps)
                    {
                        tupleSpace = servernovo.GetTupleSpace();
                    }
                    ChannelServices.UnregisterChannel(channelnovo);
                }
                catch { }
            }
        }