Archived

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

Would you help me to write a AMD-Hello?Thanks !

Hi all:
I implement an "AMI" program,and feel good.Now I want to write a AMD program.But it seems not so easy.
I use the Hello interface at Ice-2.1.0/demo/Ice/hello/.Add ["amd"] to the op sayHello.Then slice2cpp Hello.ice.
In Hello.h,I find the class AMD_Hello_sayHello and his member f such as "ice_response" and 3 "ice_exception".
My first problem : How to write HelloI.h and HelloI.cpp for server ? Shall I add
*****
virtual void sayHello_async(const ::Demo::AMD_Hello_sayHelloPtr&, const ::Ice::Current& = ::Ice::Current()) const = 0;
****
to HelloI.h ? I do this and implement it in HelloI.cpp.Then I got a compile error :
compile error begin
Server.cpp:19: error: cannot allocate an object of type `HelloI'
Server.cpp:19: error: because the following virtual functions are abstract:
./Hello.h:227: error: virtual void Demo::Hello::sayHello_async(const Demo::AMD_Hello_sayHelloPtr&, const Ice::Current&) const
compile error end

My second problem :How to write the client ?
According to "http://www.zeroc.com/forums/archive/index.php/t-927.html"
, the client side need not to change.
But ,if the client does not change,how does the new "response" "exception" work ?

I am sorry for my poor english!

ps : My env redhat linux as4,c++,Ice-2.1.0
As far as I googled,a good sample code of AMD is very very needed.

Many thanks !

Comments

  • benoit
    benoit Rennes, France
    Hi,

    Yes, you should declare and implement the sayHello_async method in your HelloI.h/HelloI.cpp files. Whether or not the server is using AMD is transparent to the client so the client doesn't need to be changed. If the AMD call results in an exception (i.e.: you call ice_exception on the AMD callback) the exception will be propagated to the client just like for regular calls.

    Ice 2.1.0 is quite old, I recommend upgrading to Ice 3.2b. Furthermore, we've added an AMI/AMD demo with Ice 3.2b, you should take a look at it to figure out how to write your server :). The demo is located in the demo/Ice/async directory.

    Cheers,
    Benoit.