Пример #1
0
        //args: id, serviceURL, entryURL
        static void Main(string[] args)
        {
            if (args.Length <= 1)
            {
                Logger.LogErr("Error: Invalid arguments. Usage: [required: id, pmUrl, serviceURL], [optional: entryURL]");
            }

            try
            {
                Node node = new Node(args[0], args[1], args[2]);
                BinaryServerFormatterSinkProvider provider = new BinaryServerFormatterSinkProvider();
                IDictionary props = new Hashtable();
                props["port"] = node.channelPort;
                props["timeout"] = 3000; // in milliseconds
                props["connectionTimeout"] = 3000;
                TcpChannel myChannel = new TcpChannel(props, null, provider);
                node.SetTcpChannel(myChannel);
                ChannelServices.RegisterChannel(myChannel, true);
                RemotingServices.Marshal(node, serviceName, typeof(IWorker));
                Logger.LogInfo("Registered node " + args[0] + " with url: " + node.myURL);
                if (args.Length >= 4)
                {
                    Logger.LogInfo("Registering on network with entry point: " + args[3]);
                    node.Register(args[3]);
                }
            }
            catch (RemotingException re)
            {
                Logger.LogErr("Remoting Exception: " + re.StackTrace);
            }
            Console.ReadLine();
        }
Пример #2
0
        //args: id, serviceURL, entryURL
        static void Main(string[] args)
        {
            if (args.Length <= 1)
            {
                Logger.LogErr("Error: Invalid arguments. Usage: [required: id, serviceURL], [optional: entryURL]");
            }

            try
            {
                Node node = new Node(args[0], args[1]);
                TcpChannel myChannel = new TcpChannel(node.channelPort);
                ChannelServices.RegisterChannel(myChannel, true);
                RemotingServices.Marshal(node, serviceName, typeof(IWorker));
                Logger.LogInfo("Registered with url: " + node.myURL);
                if (args.Length >= 3)
                {
                    Logger.LogInfo("Registering on network with entry point: " + args[2]);
                    node.Register(args[2]);
                }
            }
            catch (RemotingException re)
            {
                Logger.LogErr("Remoting Exception: " + re.StackTrace);
            }
            Console.ReadLine();
        }