Home Help Center

Manipulating a callback proxy in the client code


I have a callback based application. On the client side I want to have a managing object which gets the data from the callback proxy, and uses it as appropriate.

I thought that the callback proxy can be the managing object itself, and I guess it can, if I implement everything in the callback proxy class.

However, I was thinking to have an object which somehow includes the callback proxy, so that when data arrives on the callback, proxy, the callback proxy will notify the object it is included in. The managing object can then retrive the data and use it. I wonder now, if the principles explained in section 6.11.1 (Proxy Classes and Proxy Handles) of the Ice documentation for Ice 1.4.0 (especially page 157) apply in this situation, and if they are the reason why this approach is not feasible. It says there:
Client-side application code never manipulates proxy class instances directly. In fact, you are not allowed to instantiate a proxy class directly....
I have tried to do something like this in the client:
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapter("Callback.Client");
    adapter->add(new CallBackI, Ice::stringToIdentity("callbackReceiver"));

    CallBackPrx twowayCallBack = CallBackPrx::uncheckedCast(
    // user code
    Manager *m = new Manager(3);

    m->init(twowayServant, twowayCallback);
        // among other things, this init function does:
        //     localCBPrx = twowayCallback;
        // to remember the callback proxy, and
        //     twowayServant->getProxy(twowayProxy);
        // so that the servant will know where to call back
        // in doSomething I want to do:
        //     localCBPrx->doSomethingToo(20);
I can declare and define doSometihingToo in the class which implements the callback proxy, and the program compiles and runs. However, as soon as I call it as presented here, the program will not compile anymore, because doSometihingToo is "undeclared".

What is the right way to do what I am trying to do here, and is any of the demos doing something very similar?



  • marcmarc FloridaAdministrators, ZeroC Staff Marc LaukienOrganization: ZeroC, Inc.Project: The Internet Communications Engine ZeroC Staff
    I think you are a bit confused with respect to terminology.

    The main source of confusion is usually the definition of client and server. Unfortunately, these two terms are way too overused, and have too many different meanings in different contexts. What is a client from the user persepective doesn't have to be a client from the Ice perspective.

    From the Ice perspective, think of a client as code that invokes operations on proxies, and of server that implements Ice objects to dispatch calls it receives.

    There is no special callback concept in Ice. A callback is simply a regular operation call on a proxy. The term callback is simply used if a process, that is a client from the user perspective, also implements Ice objects, and therefore is not only a client but also a server from the Ice perspective.

    You cannot implement proxies yourself. Proxies are implemented by the Ice core and generated code. They are only used to invoke operations on Ice objects. You implement Ice objects by instantiating a servant for them.

    As for the code example, I'm afraid I do not understand what you are trying to achieve. For a callback example, please have a look at demo/Ice/callback.
Sign In or Register to comment.