首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

ICE的服务器对象实现「建议收藏」

大家好,又见面了,我是你们的朋友全栈君。1、需要增加一个类继承至生成的接口类,并实现接口类的虚方法。 2、创建实现类的对象 3、调用adpater的add方法将创建的对象绑定到adapter中,并传入一个全局唯一标示符,该唯一标示可以通过如下方法生成: adapter->add(hello, communicator()->stringToIdentity(“hello”)); adapter->addWithUUID(hello); Ice::Ideentity id; id.name=”hello”; adapter->add(hello, id); 4、adapter的add和addWithUUID方法返回一个代理对象,可以将该代理对象返回给客户端让其调用代理的方法 5、在实现接口的操作方法时,在每个操作的最后一个参数都会被ice映射成const Current& current,可以通过该成员获取操作调用上下文信息 Current的定义如下: module Ice { local dictionary<string, string> Context; enum OperationMode { Normal, \Idempotent }; local struct Current { ObjectAdapter adapter; // 服务器的对象适配器,可以通过它再调用getCommunicator得到通信器 Connection con; // 连接对象 Identity id; // 服务对象标示 string facet; // string operation; // 操作的名称 OperationMode mode; // 操作模式 Context ctx; // 操作上下文属性 int requestId; // 请求ID };

01
领券