예제 #1
0
        private bool BroadcastRemove(DIDATuple didatuple, string[] lines)
        {
            int  numberOfActiveServers = 1;
            bool ack          = false;
            int  numberOfAcks = 1;

            do
            {
                foreach (string line in lines)
                {
                    //port : name : priority
                    string[] args        = line.Split(':');
                    int      server_port = Int32.Parse(args[0]);
                    string   server_name = args[1];

                    if (didatuple.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);

                            ack = servernovo.XLBroadcastRemove(didatuple);
                            ChannelServices.UnregisterChannel(channelnovo);

                            if (ack)
                            {
                                numberOfAcks++;
                            }
                            else
                            {
                                break;
                            }

                            numberOfActiveServers++;
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
            } while (numberOfAcks != numberOfActiveServers);

            return(true);
        }