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

            CallbackSenderPrx server = CallbackSenderPrxHelper.checkedCast(
                communicator().propertyToProxy("CallbackSender.Proxy"));

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

            Ice.ObjectAdapter adapter = communicator().createObjectAdapter("");
            Ice.Identity      ident   = new Ice.Identity();
            ident.name     = Guid.NewGuid().ToString();
            ident.category = "";
            adapter.add(new CallbackReceiverI(), ident);
            adapter.activate();
            server.ice_getConnection().setAdapter(adapter);
            server.addClient(ident);
            communicator().waitForShutdown();

            return(0);
        }
Exemplo n.º 2
0
    private static int run(Ice.Communicator communicator)
    {
        var server = CallbackSenderPrxHelper.checkedCast(communicator.propertyToProxy("CallbackSender.Proxy"));

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

        //
        // Create an object adapter with no name and no endpoints for receiving callbacks
        // over bidirectional connections.
        //
        var adapter = communicator.createObjectAdapter("");

        //
        // Register the callback receiver servant with the object adapter
        //
        var proxy = CallbackReceiverPrxHelper.uncheckedCast(adapter.addWithUUID(new CallbackReceiverI()));

        //
        // Associate the object adapter with the bidirectional connection.
        //
        server.ice_getConnection().setAdapter(adapter);

        //
        // Provide the proxy of the callback receiver object to the server and wait for
        // shutdown.
        //
        server.addClient(proxy);
        communicator.waitForShutdown();
        return(0);
    }
Exemplo n.º 3
0
    private static int Init()
    {
        int result = 0;

        try
        {
            Ice.Communicator communicator = Ice.Util.initialize("config.client");

            sender = CallbackSenderPrxHelper.checkedCast(communicator.propertyToProxy("CallbackSender.Proxy").
                                                         ice_twoway().ice_timeout(-1).ice_secure(false));
            if (sender == null)
            {
                Console.Error.WriteLine("invalid proxy");
                result = 0;
            }

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

            receiver = CallbackReceiverPrxHelper.uncheckedCast(
                adapter.createProxy(Ice.Util.stringToIdentity("callbackReceiver")));

            Console.WriteLine("server connected");

            result = 1;
        }
        catch (Exception ex)
        {
            Console.Error.WriteLine(ex);

            Console.WriteLine("connection failed");
            result = 0;
        }

        return(result);
    }
Exemplo n.º 4
0
    private static int run(Ice.Communicator communicator)
    {
        var 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);
        }

        var adapter = communicator.createObjectAdapter("Callback.Client");

        adapter.add(new CallbackReceiverI(), Ice.Util.stringToIdentity("callbackReceiver"));
        adapter.activate();

        var receiver = CallbackReceiverPrxHelper.uncheckedCast(
            adapter.createProxy(Ice.Util.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 (Exception ex)
            {
                Console.Error.WriteLine(ex);
            }
        }while(!line.Equals("x"));

        return(0);
    }
Exemplo n.º 5
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);
        }