示例#1
0
 public ClientPuppet(ConnectionPack cp)
 {
     remotePuppet = (PuppetMasterRemoteServerObject)Activator.GetObject(
         typeof(PuppetMasterRemoteServerObject),
         "tcp://" + cp.Ip + ":" + cp.Port + "/PuppetMasterRemoteServerObject");
     //TODO Exceprion
     //if (remotePuppet == null) throw new SocketException();
 }
示例#2
0
        public static void Main(string[] args)
        {
            TcpChannel channel = new TcpChannel(port);

            ChannelServices.RegisterChannel(channel, false);
            myServerObj = new PuppetMasterRemoteServerObject();
            RemotingServices.Marshal(myServerObj, "PuppetMasterRemoteServerObject", typeof(PuppetMasterRemoteServerObject));

            Console.ForegroundColor = ConsoleColor.Green;
            System.Console.WriteLine("PuppetMaster Server Online : port: " + port);
            Console.ResetColor();
            System.Console.WriteLine("<enter> to exit...");

            System.Console.WriteLine("Hello, World! Im Controller and I will be your captain today");

            string       configFileLocation;
            ServerPuppet sp = ServerPuppet.Instance;

            if (args.Length > 0)
            {
                configFileLocation = args [0];
                sp.readCommandsFromFile(@configFileLocation);
            }

            System.Console.WriteLine("we are now in manual writing commands, write EXIT to stop");
            string line = System.Console.ReadLine();

            while (!line.Equals("exit", StringComparison.OrdinalIgnoreCase))
            {
                sp.doCommand(line);
                line = System.Console.ReadLine();
            }

            System.Console.WriteLine("Goodbye World! It was a pleasure to serve you today");
            Console.ForegroundColor = ConsoleColor.Red;
            System.Console.WriteLine("Puppet Server is going OFFLINE");
            Console.ResetColor();
            sp.killRemainingOperators();
            Thread.Sleep(100);//Ensuring everything is offline
        }