示例#1
0
        private void BroadcastAdd(DIDATuple didaAdd)
        {
            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];

                if (didaAdd.getName() != server_name)
                {
                    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);
                        servernovo.Add(didaAdd);
                        ChannelServices.UnregisterChannel(channelnovo);
                    }
                    catch
                    {
                    }
                }
            }
        }
示例#2
0
 private IDIDATuple Add(IDIDATuple didatuple)
 {
     return(server.Add(didatuple));
 }