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;

本文档详细介绍了如何通过C++的Dll实现IceBox服务,包括服务器端和客户端的代码编写,以及相应的配置文件设置。在服务器端,配置文件包括config.icebox和config.service,客户端配置为config.client。启动服务器需要运行命令`icebox --Ice.Config=config.icebox`,客户端则直接运行`client`。确保在Release目录下运行动态库服务和客户端应用。
最低0.47元/天 解锁文章
2728

被折叠的 条评论
为什么被折叠?



