Beispiel #1
0
    public static int Main(string[] args)
    {
        Menu();

        int key = -1;

        do
        {
            try
            {
                Console.Out.Write("==> ");
                Console.Out.Flush();
                key = Convert.ToInt32(Console.In.ReadLine());

                if (key == -1)
                {
                    break;
                }

                switch (key)
                {
                case 0:
                    Menu();
                    break;

                case 1:
                    Init();
                    break;

                case 2:
                    string message;
                    message = Console.In.ReadLine();
                    sender.initiateCallback(receiver, message);
                    break;

                case 3:
                    return(0);

                default:
                    Console.Out.WriteLine("unknown command `" + key + "'");
                    Menu();
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }while (!key.Equals(3));

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

            CallbackSenderPrx sender = CallbackSenderPrxHelper.checkedCast(
                communicator().propertyToProxy("CallbackSender.Proxy").
                ice_twoway().ice_timeout(-1).ice_secure(false));

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

            Ice.ObjectAdapter adapter = communicator().createObjectAdapter("Callback.Client");
            adapter.add(new CallbackReceiverI(), communicator().stringToIdentity("callbackReceiver"));
            adapter.activate();

            CallbackReceiverPrx receiver = CallbackReceiverPrxHelper.uncheckedCast(
                adapter.createProxy(communicator().stringToIdentity("callbackReceiver")));

            menu();

            string line = null;

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

            return(0);
        }