Пример #1
0
        public PublisherForm(string[] args)
        {
            InitializeComponent();
            logFormat("Started Process, pid=\"{0}\"", Process.GetCurrentProcess().Id);
            Text = "Publisher ";
            int nargs = 6;
            if (args.Length != nargs)
            {
                logFormat("Expected {0} arguments, got {1}", nargs, args.Length);
                return;
            }
            string puppetMasterURI = args[0];
            string name = args[1];
            string site = args[2];
            int port = int.Parse(args[3]);
            string addr = args[4];
            string processName = args[5];
            string channelURI = Utility.setupChannel(port);
            Text = string.Format("{0} {1}", processName, site);

            // get the puppetMaster that started this process
            PuppetMaster pm = (PuppetMaster)Activator.GetObject(typeof(PuppetMaster), puppetMasterURI);
            PublisherRemote publisher = new PublisherRemote(this,pm, name, site, addr,processName);
            //we need to register each remote object
            ObjRef o = RemotingServices.Marshal(publisher, name, typeof(Publisher));
            publisher.setURI(string.Format("{0}/{1}", channelURI, name));
            log(publisher.ToString());
            //now that broker is created and marshalled
            //send remote to puppetMaster which is Monitor.waiting for the remote
            pm.registerPublisher(publisher);
            logFormat("Just registered at puppetMaster");
            logFormat("Press key to leave");
        }