Archived

This forum has been archived. Please start a new discussion on GitHub.

Client-side objects

Hello.



I'm still new to this Ice-universe, but I have played around with it a bit, so now I have a question.


In all the demo's I have tried I can see that the object is created on the server-side and the client then uses the functions in that object. In the hello-demo the object = new HelloI; is on the server-side and the client uses the function hello->sayHello() to say hello on the server.
Is it possible to make this so, that the object would be on the client side, so that the client sends an object or similar to the server and the server then executes the stuff inside the object? The server-side should only know that there is a function sayHello() but not what it does. The sayHello() could just print a string like the demo or it could do some calculations and then print the result?

I use Ice-E on a Gumstix and on PC with Ubuntu. My programs are in C++.

Maybe this question have been answered before but I couldn't find any that matched this, but I might have searched with the wrong words!?

Thanks for any help in advance.
Kenni

Comments

  • matthew
    matthew NL, Canada
    With Ice you can pass objects by proxy, or by value. See my article Proxies in http://www.zeroc.com/newsletter/issue23.pdf for more details about proxies.

    If you pass an object by proxy, you are providing the recipient of the proxy the means to execute methods on the Ice object referred to by that proxy.
    interface Action
    {
      void doit();
    };
    
    interface Execute
    {
      void ex(Action* action);       
    };
    

    In this case the Action object is passed by proxy to the ex operation in the Execute object. When "pass by proxy" is used, the Ice object itself does not go over the wire, only information used to make invocations on that Ice object (the identity, facet, and optionally location information).

    If you pass an object by-value, then you are passing the object itself over the wire. In this case, assuming the object is abstract (that is, has operations) the recipient must provide an implementation of the object through an ObjectFactory.
    interface Execute
    {
      void ex(Action action);
    };
    

    This this case Action is passed by value. The recipient must provide an implementation on this interface. There is no automatic way, and nor would it be safe to do so in any case, to pass the implementation of the object over the wire. In a strictly controlled environment you could do this yourself, however.