Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Active " + args[0] + " " + args[1]);
            //char[] delimiters = { ':', '/' };
            BrokerService.brokerData.Name = args[0];
            BrokerService.brokerData.Port = args[1];
            string port  = BrokerService.brokerData.Port;
            int    porto = Int32.Parse(port);


            TcpChannel chan = new TcpChannel(porto);

            ChannelServices.RegisterChannel(chan, false);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(BrokerService), "Broker",
                WellKnownObjectMode.Singleton);
            // Get the PSlaveInterface instance that is registerd at port 8086
            PSlavesInterface slave = (PSlavesInterface)Activator.GetObject(typeof(PSlavesInterface),
                                                                           "tcp://localhost:" + args[2] + "/Slave");

            Console.WriteLine("Connected to slave: " + "tcp://localhost:" + args[2] + "/Slave");
            BrokerService.slave = slave;
            BrokerService.slave.RegisterBroker(args[1], args[0]);
            Console.ReadLine();
        }
Exemplo n.º 2
0
        public void RegisterSlaves(string newPort, string name, string father)
        {
            form.Invoke(new DelAddMsgToLog(form.sendMessageToLog1), "Trying ..." + "tcp://localhost:" + newPort + "/Slave");

            PSlavesInterface newSlave = (PSlavesInterface)Activator.GetObject(typeof(PSlavesInterface),
                                                                              "tcp://localhost:" + newPort + "/Slave");

            // form.Invoke(new DelAddMsgToLog(form.sendMessageToLog1), "Saving Slave: " + name + "in Master");

            slaves.Add(newSlave);

            slavesRegistry.Add(newPort, "tcp://localhost:" + newPort + "/Slave");
        }
Exemplo n.º 3
0
        private void sendMessageToSlave(object sender, EventArgs e)
        {
            string sitePort = portBox.Text;

            string url = PMService.getSlaveUrlByPort(sitePort);

            if (url != null)
            {
                // Get the PMServerInterface instance that is registerd at port 8086
                PSlavesInterface slave = (PSlavesInterface)Activator.GetObject(
                    typeof(PSlavesInterface),
                    "tcp://localhost:" + sitePort + "/Slave");

                slave.MsgToSlave(messageBox.Text);
            }
        }
Exemplo n.º 4
0
 public void setRemoteInterface(string url)
 {
     if (url.Equals("8086"))
     {
         SingleMachine = true;
         PMServerInterface remotePMservice = (PMServerInterface)Activator.
                                             GetObject(typeof(PMServerInterface),
                                                       "tcp://localhost:8086/RemotePMService");
         Console.WriteLine("Connected: " + "tcp://localhost:8086/RemotePMService");
         this.remotePM = remotePMservice;
         this.remotePM.MsgToMaster("Connection with broker: " + brokerData.name + " Estabilshed");
     }
     else
     {
         SingleMachine = false;
         PSlavesInterface slave = (PSlavesInterface)Activator.GetObject(typeof(PSlavesInterface),
                                                                        "tcp://localhost:" + url + "/Slave");
         Console.WriteLine("Connected to remoteSlave: " + url);
         remoteSlave = slave;
     }
 }