//# //# Corba Time Client //# $Revision: 1.1 $ //# Copyright 2004 by Eric Y. Theriault //# All Rights Reserved. //# http://www.eyt.ca/CORBA //# using System; using System.Runtime.Remoting; using System.Runtime.Remoting.Services; using System.Runtime.Remoting.Channels; using Ch.Elca.Iiop; using Ch.Elca.Iiop.Services; using omg.org.CosNaming; namespace ca.eyt.corba { /// /// Implements a class to acquire the Time from a CORBA server. /// public class TimeClient { /// /// Main. /// [System.STAThread] public static void Main( string[] args ) { try { // Create and Initialize the ORB CorbaInit orb = CorbaInit.GetInit(); // Register client channel IiopClientChannel clientChannel = new IiopClientChannel(); ChannelServices.RegisterChannel( clientChannel ); // Get the root naming context NamingContext nameService = ORBHelper.resolveNameserviceReference( orb, args ); String Time = "Time"; NameComponent[] name = new NameComponent[] { new NameComponent( Time, "" ) }; // Resolve the ior into an object. TimeTools.Time timeImpl = (TimeTools.Time)nameService.resolve( name ); // OK. Let's call the Time interface's methods. TimeTools.TimeOfDay time = timeImpl.getTime(); System.Console.Out.WriteLine( "Time server's time is: {0}:{1}:{2}", time.hour, time.minute, time.second ); } catch ( System.Exception e ) { System.Console.WriteLine( "Exception: " + e.Message ); System.Console.WriteLine( e.StackTrace.ToString() ); System.Environment.Exit( 1 ); } System.Environment.Exit( 0 ); } } }