C++的Dll来实现IceBox的服务

本文档详细介绍了如何通过C++的Dll实现IceBox服务,包括服务器端和客户端的代码编写,以及相应的配置文件设置。在服务器端,配置文件包括config.icebox和config.service,客户端配置为config.client。启动服务器需要运行命令`icebox --Ice.Config=config.icebox`,客户端则直接运行`client`。确保在Release目录下运行动态库服务和客户端应用。
摘要由CSDN通过智能技术生成

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值