As I said whether or not the client uses AMI is irrelevant from a server side point of view. The server cannot tell whether the server uses AMI or not -- an AMI call looks just like a synchronous call. On the server side you need to implement sendQuery_async -- if you cannot work out what the signature of this method should be then take a look at the generated code. What problem do you have precisely? Did you read the article "asynchronous programming" in our Connections newsletter (see
http://www.zeroc.com/newsletter for more details).
Thank you Matthew for your reply, and especially for your suggestion as far as concurrent programming is concerned: I appreciated it a lot.
I know well that AMI and AMD are independent from each other, but the problem here is that I do not know how I can implement the signature of the AMD class.
I've already read several times the Chat example presented in the 4th Issue of your newsletter, but due to the fact that I'm quite hard minded, it represents for me an argument pretty hard to be dealt with if I consider those two asynchronous facilities taken together for a single method (which is the sendQuery()).
In the AMI "only" version of the project I have, in the file AMISqlI.cpp, this signature:
Code:
std::string
AMISqlI::sendQuery(const std::string& s, const Ice::Current&)
{
...
}
and in the AMI callback there is the code wrote in the last post.
In the Server.cpp I instantiate a new Ice object
Code:
Ice::ObjectPtr object = new AMISqlI;
This is the original slice definition:
Code:
module Demo
{
interface AMISql {
["ami"] string sendQuery(string query);
idempotent void shutdown();
};
};
The AMI version of the project works properly, and now I want to add the AMD functionality.
If I only add the "amd" tag in the slice definition I get this error:
error C2259: 'AMISqlI' : cannot instantiate abstract class
due to following members:
'void Demo::AMISql::sendQuery_async(const Demo::AMD_AMISql_sendQueryPtr &,const std::string &,const Ice::Current &)' : is abstract
c:\documents and settings\alberto\documenti\visual studio 2005\projects\amisql\amisql_server\amisql.h(252) : see declaration of 'Demo::AMISql::sendQuery_async'
So I deduce that a signature of the function [I]AMD_AMISql_sendQuery_async [/]was missing, so I added this function in the file AMISqlI.cpp:
Code:
void AMISqlI::sendQuery_async(const Demo::AMD_AMISql_sendQueryPtr& _cb, const std::string& s, const Ice::Current& c)
{
...//the same code as the "normal" sendQuery... is that right?
}
What direction should I take?
I want the response of the server not tied to the return of the operation.
Thank you in advance
Alberto