Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("@broker !!! porto -> {0}", args[0]);

            string[] arguments = args[0].Split(';');//arguments[0]->port; arguments[1]->url; arguments[2]->nome; arguments[3]->site;

            int vizinhos = arguments.Length - 5;//numero de vizinhos
            List<Broker> lstaux = new List<Broker>();
            //iniciar lista de vizinhos
            for (int i = 4; i < vizinhos + 4; i++) {
                string[] atr = arguments[i].Split('%');//atr[0]-site, atr[1]-url, atr[2]-nome
                Broker b = new Broker(atr[1], atr[2], atr[0]);
                lstaux.Add(b);
            }

            TcpChannel channel = new TcpChannel(Int32.Parse(arguments[0]));
            ChannelServices.RegisterChannel(channel, true);

            BrokerCommunication brokerbroker = new BrokerCommunication(lstaux, arguments[2]);
            RemotingServices.Marshal(brokerbroker, "BrokerCommunication", typeof(BrokerCommunication));

            MPMBrokerCmd processCmd = new MPMBrokerCmd();
            RemotingServices.Marshal(processCmd, "MPMProcessCmd", typeof(MPMBrokerCmd));

            Console.ReadLine();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Console.WriteLine("@broker !!! porto -> {0}", args[0]);

            string[] arguments = args[0].Split(';');//arguments[0]->port; arguments[1]->url; arguments[2]->nome; arguments[3]->site; arguments[4]->replicas;

            int vizinhos = arguments.Length - 6;//numero de vizinhos
            List<Broker> lstaux = new List<Broker>();
            //iniciar lista de vizinhos
            for (int i = 5; i < vizinhos + 5; i++) {
                string[] atr = arguments[i].Split('%');//atr[0]-name, atr[1]-site, atr[2]-url
                Broker b = new Broker(atr[2], atr[0], atr[1]);
                lstaux.Add(b);
            }

            string aux = arguments[4].Substring(0,arguments[4].Length -1); // retirar # do fim da string "replica#replica#"
            string[] rep =aux.Split('#');
            List<string> replicas = new List<string>();
            //iniciar lista de replicas
            foreach(var r in rep){
                replicas.Add(r);
            }
            TcpChannel channel = new TcpChannel(Int32.Parse(arguments[0]));
            ChannelServices.RegisterChannel(channel, true);

            BrokerCommunication brokerbroker = new BrokerCommunication(lstaux, arguments[2], replicas, arguments[0] );
            RemotingServices.Marshal(brokerbroker, "BrokerCommunication", typeof(BrokerCommunication));

            MPMBrokerCmd processCmd = new MPMBrokerCmd();
            RemotingServices.Marshal(processCmd, "MPMProcessCmd", typeof(MPMBrokerCmd));

            Console.ReadLine();
        }