static void Main(string[] args) { RemotingConfiguration.Configure("HelloClient.exe.config"); Hello obj = new Hello(); if (obj == null) { Console.WriteLine("could not locate server"); return; } CallContextData cookie = new CallContextData(); cookie.Data = "information for the server"; CallContext.SetData("mycookie", cookie); for (int i=0; i< 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } for (int i=0; i< 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { RemotingConfiguration.Configure("HelloClient.exe.config"); Hello obj = new Hello(); if (obj == null) { Console.WriteLine("could not locate server"); return; } CallContextData cookie = new CallContextData(); cookie.Data = "information for the server"; CallContext.SetData("mycookie", cookie); for (int i = 0; i < 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } for (int i = 0; i < 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { TrackingServices.RegisterTrackingHandler(new TrackingHandler()); ChannelServices.RegisterChannel(new TcpClientChannel()); ChannelServices.RegisterChannel(new HttpClientChannel()); RemotingConfiguration.RegisterWellKnownClientType( typeof(Wrox.ProfessionalCSharp.Hello), "tcp://localhost:8086/Hi"); /* Hello obj = (Hello)Activator.GetObject( typeof(Wrox.ProfessionalCSharp.Hello), "tcp://localhost:8086/Hi"); */ Hello obj = new Hello(); // Hello obj = (Hello)RemotingServices.Connect(typeof(Wrox.ProfessionalCSharp.Hello), // "http://localhost:8085/Hi"); if (obj == null) { Console.WriteLine("could not locate server"); return; } for (int i=0; i< 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { TrackingServices.RegisterTrackingHandler(new TrackingHandler()); ChannelServices.RegisterChannel(new TcpClientChannel()); ChannelServices.RegisterChannel(new HttpClientChannel()); RemotingConfiguration.RegisterWellKnownClientType( typeof(Wrox.ProfessionalCSharp.Hello), "tcp://localhost:8086/Hi"); /* Hello obj = (Hello)Activator.GetObject( * typeof(Wrox.ProfessionalCSharp.Hello), * "tcp://localhost:8086/Hi"); */ Hello obj = new Hello(); // Hello obj = (Hello)RemotingServices.Connect(typeof(Wrox.ProfessionalCSharp.Hello), // "http://localhost:8085/Hi"); if (obj == null) { Console.WriteLine("could not locate server"); return; } for (int i = 0; i < 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { RemotingConfiguration.Configure("HelloClient.exe.config"); Hello obj = new Hello(); if (obj == null) { Console.WriteLine("could not locate server"); return; } for (int i=0; i< 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { RemotingConfiguration.Configure("HelloClient.exe.config"); Hello obj = new Hello(); if (obj == null) { Console.WriteLine("could not locate server"); return; } for (int i = 0; i < 5; i++) { Console.WriteLine(obj.Greeting("Christian")); } }
static void Main(string[] args) { ChannelServices.RegisterChannel(new TcpClientChannel()); // ChannelServices.RegisterChannel(new HttpClientChannel()); // using the Activator class to create remote objects object[] attrs = { new UrlAttribute("tcp://localhost:8086/HelloServer") }; ObjectHandle handle = Activator.CreateInstance( "RemoteHello", "Wrox.ProfessionalCSharp.Hello", attrs); // Hello obj = (Hello)Activator.CreateInstance(typeof(Wrox.ProfessionalCSharp.Hello), // null, attrs); if (handle == null) { Console.WriteLine("could not locate server"); return; } Hello obj = (Hello)handle.Unwrap(); // using the new operator to create remote objects /* RemotingConfiguration.RegisterActivatedClientType( * typeof(Wrox.ProfessionalCSharp.Hello), * "tcp://localhost:8086/HelloServer"); * * Hello obj = new Hello(); */ if (RemotingServices.IsTransparentProxy(obj)) { //Console.WriteLine("Using a transparent proxy"); RealProxy proxy = RemotingServices.GetRealProxy(obj); // proxy.Invoke(message); } ILease lease = (ILease)obj.GetLifetimeService(); if (lease != null) { Console.WriteLine("Lease Configuration:"); Console.WriteLine("InitialLeaseTime: " + lease.InitialLeaseTime); Console.WriteLine("RenewOnCallTime: " + lease.RenewOnCallTime); Console.WriteLine("SponsorshipTimeout: " + lease.SponsorshipTimeout); Console.WriteLine(lease.CurrentLeaseTime); } Console.WriteLine(obj.Greeting("Christian")); /* * for (int i=0; i< 5; i++) * { * Console.WriteLine(obj.Greeting("Christian")); * }*/ }