public static void Main(string[] args) { int count = 66; string location = "Londres"; //if (args.Length != 2) //{ // Console.WriteLine("Gumballs <location> <inventory>"); // Environment.Exit(1); //} //location = args[0]; //count = int.Parse(args[1]); GumballMachine gumballMachine = new GumballMachine(count, location); Console.WriteLine("Starting Gumball server..."); try { HttpChannel channel = new HttpChannel(9998); ChannelServices.RegisterChannel(channel, false); RemotingServices.Marshal(gumballMachine, "GumballMachine"); Console.WriteLine("Press Enter to quit\n\n"); Console.ReadLine(); } catch (Exception e) { throw new RemoteException(e.Message, e); } }
static void Main(string[] args) { try { var channel = new HttpChannel(); ChannelServices.RegisterChannel(channel, false); var gumballMachineRemote = (IGumballMachineRemote)Activator.GetObject( typeof(IGumballMachineRemote), "http://localhost:9998/GumballMachine"); var monitor = new GumballMonitor(gumballMachineRemote); monitor.printReport(); } catch (Exception e) { throw new RemoteException(e.Message, e); } var gumballMachine = new GumballMachine(15, "Madrid"); var gumballMonitor = new GumballMonitor(gumballMachine); gumballMonitor.printReport(); //for (int i = 0; i < 20; i++) //{ // gumballMachine.insertQuarter(); // gumballMachine.trunCrank(); //} Console.ReadLine(); }