1、服务器端代码:
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
#include "Hello.h"
#include <iostream>
using namespace std;
#if defined(_WIN32)
#define HELLO_API __declspec(dllexport)
#else
#define HELLO_API /**/
#endif
class HELLO_API HelloI : public Demo::Hello{
public:
virtual void sayHello(const Ice::Current& c){cout << "Hello World!" << endl;}
};
class HELLO_API CHelloServerService : public ::IceBox::Service
{
public:
CHelloServerService(){}
virtual ~CHelloServerService(){}
virtual void start(const ::std::string& name, const ::Ice::CommunicatorPtr& communicator,const ::Ice::StringSeq& args){
spAdapter = communicator->createObjectAdapter(name);
spAdapter->add(new HelloI, communicator->stringToIdentity(name));
spAdapter->activate();
}
virtual void stop(){spAdapter->destroy();}
private:
::Ice::ObjectAdapterPtr spAdapter;
};
extern "C"{
HELLO_API IceBox::Service* Create(Ice::CommunicatorPtr communicator){
return new CHelloServerService();
}
}
2、客户端代码:
#include <Ice/Ice.h>
#incl