예제 #1
0
        /// <summary>
        /// Run the agent as an application
        /// </summary>
        /// <param name="args"></param>
        /// <example>Debug Commandline arguments: /zone test /url http://127.0.0.1:7080/test</example>
        public static void Main(String[] args)
        {
            SimpleSubscriber agent = null;

            try {
                if (args.Length < 2)
                {
                    Console.WriteLine
                        ("Usage: SimpleSubscriber /zone zone /url url [/full] [options]");
                    AdkExamples.printHelp(); // /zone test /url http://127.0.0.1:7080/test
                    return;
                }

                //	Pre-parse the command-line before initializing the Adk
                Adk.Debug = AdkDebugFlags.None;
                AdkExamples.parseCL(null, args);

                //  Initialize the Adk with the specified version, loading only the learner SDO package
                Adk.Initialize(AdkExamples.Version, SIFVariant.SIF_US, (int)SdoLibraryType.Student);

                //  Start the agent...
                agent = new SimpleSubscriber();

                // Call StartAgent. This method does not return until the agent shuts down
                agent.startAgent(args);

                //	Wait for Ctrl-C to be pressed
                Console.WriteLine("Agent is running (Press Ctrl-C to stop)");
                new AdkConsoleWait().WaitForExit();
            }
            catch (Exception e) {
                Console.WriteLine(e);
            }
            finally {
                if (agent != null && agent.Initialized)
                {
                    //  Always shutdown the agent on exit
                    try {
                        agent.Shutdown
                            (AdkExamples.Unreg
                                  ? ProvisioningFlags.Unprovide
                                  : ProvisioningFlags.None);
                    }
                    catch (AdkException adkEx) {
                        Console.WriteLine(adkEx);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Run the agent as an application
        /// </summary>
        /// <param name="args"></param>
        /// <example>Debug Commandline arguments: /zone test /url http://127.0.0.1:7080/test</example>
        public static void Main( String[] args )
        {
            SimpleSubscriber agent = null;
            try {
                if ( args.Length < 2 ) {
                    Console.WriteLine
                        ( "Usage: SimpleSubscriber /zone zone /url url [/full] [options]" );
                    AdkExamples.printHelp(); // /zone test /url http://127.0.0.1:7080/test
                    return;
                }

                //	Pre-parse the command-line before initializing the Adk
                Adk.Debug = AdkDebugFlags.None;
                AdkExamples.parseCL( null, args );

                //  Initialize the Adk with the specified version, loading only the learner SDO package
                Adk.Initialize( AdkExamples.Version, SIFVariant.SIF_US, (int)SdoLibraryType.Student );

                //  Start the agent...
                agent = new SimpleSubscriber();

                // Call StartAgent. This method does not return until the agent shuts down
                agent.startAgent( args );

                //	Wait for Ctrl-C to be pressed
                Console.WriteLine( "Agent is running (Press Ctrl-C to stop)" );
                new AdkConsoleWait().WaitForExit();
            }
            catch ( Exception e ) {
                Console.WriteLine( e );
            }
            finally {
                if ( agent != null && agent.Initialized ) {
                    //  Always shutdown the agent on exit
                    try {
                        agent.Shutdown
                            ( AdkExamples.Unreg
                                  ? ProvisioningFlags.Unprovide
                                  : ProvisioningFlags.None );
                    }
                    catch ( AdkException adkEx ) {
                        Console.WriteLine( adkEx );
                    }
                }
            }
        }