Exemplo n.º 1
0
 public override void sendGreeting(MyGreeting greeting, Ice.Current current)
 {
     if (greeting != null)
     {
         System.Console.Out.WriteLine(greeting.text);
     }
     else
     {
         System.Console.Out.WriteLine("Received null greeting!");
     }
 }
Exemplo n.º 2
0
    private static int run(Ice.Communicator communicator)
    {
        var greet = GreetPrxHelper.checkedCast(communicator.propertyToProxy("Greet.Proxy"));

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

        var greeting = new MyGreeting();

        greeting.text = "Hello there!";
        MyGreeting nullGreeting = null;

        bool sendNull = false;

        menu();

        string line = null;

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

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

            GreetPrx greet = GreetPrxHelper.checkedCast(communicator().propertyToProxy("Greet.Proxy"));

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

            MyGreeting greeting = new MyGreeting();

            greeting.text = "Hello there!";
            MyGreeting nullGreeting = null;

            bool sendNull = false;

            menu();

            string line = null;

            do
            {
                try
                {
                    Console.Out.Write("==> ");
                    Console.Out.Flush();
                    line = Console.In.ReadLine();
                    if (line == null)
                    {
                        break;
                    }
                    if (line.Equals("g"))
                    {
                        if (sendNull)
                        {
                            greet.sendGreeting(nullGreeting);
                        }
                        else
                        {
                            greet.sendGreeting(greeting);
                        }
                    }
                    else if (line.Equals("t"))
                    {
                        sendNull = !sendNull;
                    }
                    else if (line.Equals("s"))
                    {
                        greet.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);
        }