#include<Ice/Ice.h>
#include<Printer.h>
using namespace std;
class PrinterI: public Printer{
public:
virtual void printString(const string & s,const Ice::Current &);
};
void PrinterI::printString(const string & s,const Ice::Current &){
cout<<s<<endl;
}
int main(int argc,char* argc[]){
int status=0;
Ice::CommunlicatorPtr ic;
try{
ic=Ice::initialize(argc,argv);
Ice::ObjectAdapterPtr adapter = ic->createObjectAdapterWithEndpoints("SimplePrinterAdapter","default -p 10000");
Ice::OjectPtr object = new PrinterI;
adapter->add(object,Ice::stringToIdentity("SimplePrinter"));
adapter->activate();
ic->waitForShutdown();
}cacth(const Ice::Exception & e){
cerr<<e<<endl;
status=1;
}catch(const char * msg){
cerr<<msg<<endl;
status=1;
}
if(ic)
ic->destroy();
return status;
}
评论0