Beispiel #1
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            HelloPrx hello = HelloPrxHelper.checkedCast(communicator().propertyToProxy("Hello.Proxy"));

            if (hello == null)
            {
                Console.Error.WriteLine("invalid proxy");
                return(1);
            }

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Out.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("t"))
                    {
                        hello.sayHello();
                    }
                    else if (line.Equals("s"))
                    {
                        hello.shutdown();
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (System.Exception ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while (!line.Equals("x"));

            return(0);
        }
Beispiel #2
0
    private static int run(Ice.Communicator communicator)
    {
        HelloPrx twoway = HelloPrxHelper.checkedCast(
            communicator.propertyToProxy("Hello.Proxy").ice_twoway().ice_secure(false));

        if (twoway == null)
        {
            Console.Error.WriteLine("invalid proxy");
            return(1);
        }
        HelloPrx oneway        = (HelloPrx)twoway.ice_oneway();
        HelloPrx batchOneway   = (HelloPrx)twoway.ice_batchOneway();
        HelloPrx datagram      = (HelloPrx)twoway.ice_datagram();
        HelloPrx batchDatagram = (HelloPrx)twoway.ice_batchDatagram();

        bool secure  = false;
        int  timeout = -1;
        int  delay   = 0;

        menu();

        string line = null;

        do
        {
            try
            {
                Console.Out.Write("==> ");
                Console.Out.Flush();
                line = Console.In.ReadLine();
                if (line == null)
                {
                    break;
                }
                if (line.Equals("t"))
                {
                    twoway.sayHello(delay);
                }
                else if (line.Equals("o"))
                {
                    oneway.sayHello(delay);
                }
                else if (line.Equals("O"))
                {
                    batchOneway.sayHello(delay);
                }
                else if (line.Equals("d"))
                {
                    if (secure)
                    {
                        Console.WriteLine("secure datagrams are not supported");
                    }
                    else
                    {
                        datagram.sayHello(delay);
                    }
                }
                else if (line.Equals("D"))
                {
                    if (secure)
                    {
                        Console.WriteLine("secure datagrams are not supported");
                    }
                    else
                    {
                        batchDatagram.sayHello(delay);
                    }
                }
                else if (line.Equals("f"))
                {
                    batchOneway.ice_flushBatchRequests();
                    if (!secure)
                    {
                        batchDatagram.ice_flushBatchRequests();
                    }
                }
                else if (line.Equals("T"))
                {
                    if (timeout == -1)
                    {
                        timeout = 2000;
                    }
                    else
                    {
                        timeout = -1;
                    }

                    twoway      = (HelloPrx)twoway.ice_invocationTimeout(timeout);
                    oneway      = (HelloPrx)oneway.ice_invocationTimeout(timeout);
                    batchOneway = (HelloPrx)batchOneway.ice_invocationTimeout(timeout);

                    if (timeout == -1)
                    {
                        Console.WriteLine("timeout is now switched off");
                    }
                    else
                    {
                        Console.WriteLine("timeout is now set to 2000ms");
                    }
                }
                else if (line.Equals("P"))
                {
                    if (delay == 0)
                    {
                        delay = 2500;
                    }
                    else
                    {
                        delay = 0;
                    }

                    if (delay == 0)
                    {
                        Console.WriteLine("server delay is now deactivated");
                    }
                    else
                    {
                        Console.WriteLine("server delay is now set to 2500ms");
                    }
                }
                else if (line.Equals("S"))
                {
                    secure = !secure;

                    twoway        = (HelloPrx)twoway.ice_secure(secure);
                    oneway        = (HelloPrx)oneway.ice_secure(secure);
                    batchOneway   = (HelloPrx)batchOneway.ice_secure(secure);
                    datagram      = (HelloPrx)datagram.ice_secure(secure);
                    batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure);

                    if (secure)
                    {
                        Console.WriteLine("secure mode is now on");
                    }
                    else
                    {
                        Console.WriteLine("secure mode is now off");
                    }
                }
                else if (line.Equals("s"))
                {
                    twoway.shutdown();
                }
                else if (line.Equals("x"))
                {
                    // Nothing to do
                }
                else if (line.Equals("?"))
                {
                    menu();
                }
                else
                {
                    Console.WriteLine("unknown command `" + line + "'");
                    menu();
                }
            }
            catch (System.Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }while (!line.Equals("x"));

        return(0);
    }
Beispiel #3
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            try
            {
                communicator().getPluginManager().getPlugin("IceSSL");
                _haveSSL = true;
            }
            catch (Ice.NotRegisteredException)
            {
            }

            HelloPrx twoway = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello"));

            if (twoway == null)
            {
                Console.Error.WriteLine("invalid proxy");
                return(1);
            }
            HelloPrx oneway        = (HelloPrx)twoway.ice_oneway();
            HelloPrx batchOneway   = (HelloPrx)twoway.ice_batchOneway();
            HelloPrx datagram      = (HelloPrx)twoway.ice_datagram();
            HelloPrx batchDatagram = (HelloPrx)twoway.ice_batchDatagram();

            bool secure  = false;
            int  timeout = -1;
            int  delay   = 0;

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Out.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("t"))
                    {
                        twoway.sayHello(delay);
                    }
                    else if (line.Equals("o"))
                    {
                        oneway.sayHello(delay);
                    }
                    else if (line.Equals("O"))
                    {
                        batchOneway.sayHello(delay);
                    }
                    else if (line.Equals("d"))
                    {
                        if (secure)
                        {
                            Console.WriteLine("secure datagrams are not supported");
                        }
                        else
                        {
                            datagram.sayHello(delay);
                        }
                    }
                    else if (line.Equals("D"))
                    {
                        if (secure)
                        {
                            Console.WriteLine("secure datagrams are not supported");
                        }
                        else
                        {
                            batchDatagram.sayHello(delay);
                        }
                    }
                    else if (line.Equals("f"))
                    {
                        batchOneway.ice_flushBatchRequests();
                        batchDatagram.ice_flushBatchRequests();
                    }
                    else if (line.Equals("T"))
                    {
                        if (timeout == -1)
                        {
                            timeout = 2000;
                        }
                        else
                        {
                            timeout = -1;
                        }

                        twoway      = (HelloPrx)twoway.ice_invocationTimeout(timeout);
                        oneway      = (HelloPrx)oneway.ice_invocationTimeout(timeout);
                        batchOneway = (HelloPrx)batchOneway.ice_invocationTimeout(timeout);

                        if (timeout == -1)
                        {
                            Console.WriteLine("timeout is now switched off");
                        }
                        else
                        {
                            Console.WriteLine("timeout is now set to 2000ms");
                        }
                    }
                    else if (line.Equals("P"))
                    {
                        if (delay == 0)
                        {
                            delay = 2500;
                        }
                        else
                        {
                            delay = 0;
                        }

                        if (delay == 0)
                        {
                            Console.WriteLine("server delay is now deactivated");
                        }
                        else
                        {
                            Console.WriteLine("server delay is now set to 2500ms");
                        }
                    }
                    else if (_haveSSL && line.Equals("S"))
                    {
                        secure = !secure;

                        twoway        = (HelloPrx)twoway.ice_secure(secure);
                        oneway        = (HelloPrx)oneway.ice_secure(secure);
                        batchOneway   = (HelloPrx)batchOneway.ice_secure(secure);
                        datagram      = (HelloPrx)datagram.ice_secure(secure);
                        batchDatagram = (HelloPrx)batchDatagram.ice_secure(secure);

                        if (secure)
                        {
                            Console.WriteLine("secure mode is now on");
                        }
                        else
                        {
                            Console.WriteLine("secure mode is now off");
                        }
                    }
                    else if (line.Equals("s"))
                    {
                        twoway.shutdown();
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (System.Exception ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while (!line.Equals("x"));

            return(0);
        }
Beispiel #4
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            HelloPrx hello = HelloPrxHelper.checkedCast(communicator().propertyToProxy("Hello.Proxy"));

            if (hello == null)
            {
                Console.Error.WriteLine("invalid proxy");
                return(1);
            }

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Out.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("i"))
                    {
                        hello.sayHello(0);
                    }
                    else if (line.Equals("d"))
                    {
                        hello.begin_sayHello(5000).whenCompleted(
                            () => { },
                            (Ice.Exception ex) =>
                        {
                            if (ex is RequestCanceledException)
                            {
                                Console.Error.WriteLine("RequestCanceledException");
                            }
                            else
                            {
                                Console.Error.WriteLine("sayHello AMI call failed:");
                                Console.Error.WriteLine(ex);
                            }
                        });
                    }
                    else if (line.Equals("s"))
                    {
                        hello.shutdown();
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.Out.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (Ice.Exception ex)
                {
                    Console.Error.WriteLine(ex);
                }
            }while(!line.Equals("x"));

            return(0);
        }
Beispiel #5
0
    private static int run(Ice.Communicator communicator)
    {
        HelloPrx hello = null;

        try
        {
            hello = HelloPrxHelper.checkedCast(communicator.stringToProxy("hello"));
        }
        catch (Ice.NotRegisteredException)
        {
            var query =
                IceGrid.QueryPrxHelper.checkedCast(communicator.stringToProxy("DemoIceGrid/Query"));
            hello = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello"));
        }
        if (hello == null)
        {
            Console.WriteLine("couldn't find a `::Demo::Hello' object");
            return(1);
        }

        menu();

        string line = null;

        do
        {
            try
            {
                Console.Write("==> ");
                Console.Out.Flush();
                line = Console.In.ReadLine();
                if (line == null)
                {
                    break;
                }
                if (line.Equals("t"))
                {
                    hello.sayHello();
                }
                else if (line.Equals("s"))
                {
                    hello.shutdown();
                }
                else if (line.Equals("x"))
                {
                    // Nothing to do
                }
                else if (line.Equals("?"))
                {
                    menu();
                }
                else
                {
                    Console.WriteLine("unknown command `" + line + "'");
                    menu();
                }
            }
            catch (Ice.LocalException ex)
            {
                Console.WriteLine(ex);
            }
        }while(!line.Equals("x"));

        return(0);
    }
Beispiel #6
0
        public override int run(string[] args)
        {
            if (args.Length > 0)
            {
                Console.Error.WriteLine(appName() + ": too many arguments");
                return(1);
            }

            HelloPrx hello = null;

            try
            {
                hello = HelloPrxHelper.checkedCast(communicator().stringToProxy("hello"));
            }
            catch (Ice.NotRegisteredException)
            {
                IceGrid.QueryPrx query =
                    IceGrid.QueryPrxHelper.checkedCast(communicator().stringToProxy("DemoIceGrid/Query"));
                hello = HelloPrxHelper.checkedCast(query.findObjectByType("::Demo::Hello"));
            }
            if (hello == null)
            {
                Console.WriteLine("couldn't find a `::Demo::Hello' object");
                return(1);
            }

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("t"))
                    {
                        hello.sayHello();
                    }
                    else if (line.Equals("s"))
                    {
                        hello.shutdown();
                    }
                    else if (line.Equals("x"))
                    {
                        // Nothing to do
                    }
                    else if (line.Equals("?"))
                    {
                        menu();
                    }
                    else
                    {
                        Console.WriteLine("unknown command `" + line + "'");
                        menu();
                    }
                }
                catch (Ice.LocalException ex)
                {
                    Console.WriteLine(ex);
                }
            }while(!line.Equals("x"));

            return(0);
        }