当前位置: 首页 > news >正文

做外贸的国际网站有哪些郑州疫情最新动态

做外贸的国际网站有哪些,郑州疫情最新动态,wordpress外贸源码,网站开发与维护介绍IPC/RPC 提供对远端 Stub 对象状态的订阅机制, 在远端 Stub 对象消亡时,可触发消亡通知告诉本地 Proxy 对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消…

IPC/RPC 提供对远端 Stub 对象状态的订阅机制, 在远端 Stub 对象消亡时,可触发消亡通知告诉本地 Proxy 对象。这种状态通知订阅需要调用特定接口完成,当不再需要订阅时也需要调用特定接口取消。使用这种订阅机制的用户,需要实现消亡通知接口 DeathRecipient 并实现 onRemoteDied 方法清理资源。该方法会在远端 Stub 对象所在进程消亡或所在设备离开组网时被回调。值得注意的是,调用这些接口有一定的顺序。首先,需要 Proxy 订阅 Stub 消亡通知,若在订阅期间 Stub 状态正常,则在不再需要时取消订阅;若在订阅期间 Stub 所在进程退出或者所在设备退出组网,则会自动触发 Proxy 自定义的后续操作。

使用场景

这种订阅机制适用于本地 Proxy 对象需要感知远端 Stub 对象所在进程消亡,或所在设备离开组网的场景。当 Proxy 感知到 Stub 端消亡后,可适当清理本地资源。此外,RPC 目前不提供匿名 Stub 对象的消亡通知,即只有向 SAMgr 注册过的服务才能被订阅消亡通知,IPC 则支持匿名对象的消亡通知。

Native 侧接口

参考代码
 

#include "iremote_broker.h"
#include "iremote_stub.h"//定义消息码
enum {TRANS_ID_PING_ABILITY = 5,TRANS_ID_REVERSED_MONITOR
};const std::string DESCRIPTOR = "test.ITestAbility";class ITestService : public IRemoteBroker {
public:// DECLARE_INTERFACE_DESCRIPTOR是必需的,入参需使用std::u16string;DECLARE_INTERFACE_DESCRIPTOR(to_utf16(DESCRIPTOR));virtual int TestPingAbility(const std::u16string &dummy) = 0; // 定义业务函数
};class TestServiceProxy : public IRemoteProxy<ITestAbility> {
public:explicit TestAbilityProxy(const sptr<IRemoteObject> &impl);virtual int TestPingAbility(const std::u16string &dummy) override;int TestAnonymousStub();
private:static inline BrokerDelegator<TestAbilityProxy> delegator_; // 方便后续使用iface_cast宏
};TestServiceProxy::TestServiceProxy(const sptr<IRemoteObject> &impl): IRemoteProxy<ITestAbility>(impl)
{
}int TestServiceProxy::TestPingAbility(const std::u16string &dummy){MessageOption option;MessageParcel dataParcel, replyParcel;dataParcel.WriteString16(dummy);int error = PeerHolder::Remote()->SendRequest(TRANS_ID_PING_ABILITY, dataParcel, replyParcel, option);int result = (error == ERR_NONE) ? replyParcel.ReadInt32() : -1;return result;
}
#include "iremote_object.h"class TestDeathRecipient : public IRemoteObject::DeathRecipient {
public:virtual void OnRemoteDied(const wptr<IRemoteObject>& remoteObject);
}void TestDeathRecipient::OnRemoteDied(const wptr<IRemoteObject>& remoteObject)
{
}
sptr<IPCObjectProxy> object = new IPCObjectProxy(1, to_utf16(DESCRIPTOR));
sptr<IRemoteObject::DeathRecipient> deathRecipient (new TestDeathRecipient());// 构造一个消亡通知对象
bool result = object->AddDeathRecipient(deathRecipient); // 注册消亡通知
result = object->RemoveDeathRecipient(deathRecipient); // 移除消亡通知

JS 侧接口

参考代码

import FA from "@ohos.ability.featureAbility";let proxy;let connect = {    onConnect: function(elementName, remoteProxy) {        console.log("RpcClient: js onConnect called.");        proxy = remoteProxy;    },    onDisconnect: function(elementName) {        console.log("RpcClient: onDisconnect");    },    onFailed: function() {        console.log("RpcClient: onFailed");    }};let want = {    "bundleName": "com.ohos.server",    "abilityName": "com.ohos.server.MainAbility",};FA.connectAbility(want, connect);class MyDeathRecipient {    onRemoteDied() {        console.log("server died");    }}let deathRecipient = new MyDeathRecipient();proxy.addDeathRecipient(deathRecipient, 0);proxy.removeDeathRecipient(deathRecipient, 0);

Stub 感知 Proxy 消亡(匿名 Stub 的使用)

正向的消亡通知是 Proxy 感知 Stub 的状态,若想达到反向的死消亡通知,即 Stub 感知 Proxy 的状态,可以巧妙的利用正向消亡通知。如两个进程 A(原 Stub 所在进程)和 B(原 Proxy 所在进程),进程 B 在获取到进程 A 的 Proxy 对象后,在 B 进程新建一个匿名 Stub 对象(匿名指未向 SAMgr 注册),可称之为回调 Stub,再通过 SendRequest 接口将回调 Stub 传给进程 A 的原 Stub。这样一来,进程 A 便获取到了进程 B 的回调 Proxy。当进程 B 消亡或 B 所在设备离开组网时,回调 Stub 会消亡,回调 Proxy 会感知,进而通知给原 Stub,便实现了反向消亡通知。

注意:

反向死亡通知仅限设备内跨进程通信使用,不可用于跨设备。

当匿名 Stub 对象没有被任何一个 Proxy 指向的时候,内核会自动回收。

参考代码

//Proxyint TestAbilityProxy::TestAnonymousStub(){    MessageOption option;    MessageParcel dataParcel, replyParcel;    dataParcel.UpdateDataVersion(Remote());    dataParcel.WriteRemoteObject(new TestAbilityStub());    int error = Remote()->SendRequest(TRANS_ID_REVERSED_MONITOR,dataParcel, replyParcel, option);    int result = (error == ERR_NONE) ? replyParcel.ReadInt32() : -1;    return result;}
//Stub
int TestAbilityStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option){    switch (code) {        case TRANS_ID_REVERSED_MONITOR: {            sptr<IRemoteObject> obj = data.ReadRemoteObject();            if (obj == nullptr) {                reply.WriteInt32(ERR_NULL_OBJECT);                return ERR_NULL_OBJECT;            }            bool result = obj->AddDeathRecipient(new TestDeathRecipient());            result ? reply.WriteInt32(ERR_NONE) : reply.WriteInt32(-1);            break;        }        default:            break;    }    return ERR_NONE;}

文章转载自:
http://dinncogummiferous.bkqw.cn
http://dinncohyperslow.bkqw.cn
http://dinncofetch.bkqw.cn
http://dinncocentesimate.bkqw.cn
http://dinncorelearn.bkqw.cn
http://dinncodealer.bkqw.cn
http://dinncononwhite.bkqw.cn
http://dinncoabsolutism.bkqw.cn
http://dinncorecompense.bkqw.cn
http://dinncosalep.bkqw.cn
http://dinncochrismon.bkqw.cn
http://dinncopriesthood.bkqw.cn
http://dinncotoon.bkqw.cn
http://dinncolangsyne.bkqw.cn
http://dinncolib.bkqw.cn
http://dinncopancuronium.bkqw.cn
http://dinncogobble.bkqw.cn
http://dinncoupgather.bkqw.cn
http://dinncoprobable.bkqw.cn
http://dinncoleukemic.bkqw.cn
http://dinncokoksaphyz.bkqw.cn
http://dinncobfc.bkqw.cn
http://dinncomaterialman.bkqw.cn
http://dinncobiochip.bkqw.cn
http://dinncoshank.bkqw.cn
http://dinncospeechify.bkqw.cn
http://dinncobaalize.bkqw.cn
http://dinncotoe.bkqw.cn
http://dinncodisinclined.bkqw.cn
http://dinncoturf.bkqw.cn
http://dinncocolicin.bkqw.cn
http://dinncocajolery.bkqw.cn
http://dinncospecies.bkqw.cn
http://dinncoproscriptive.bkqw.cn
http://dinncomyxasthenia.bkqw.cn
http://dinncoinharmony.bkqw.cn
http://dinncophenylketonuria.bkqw.cn
http://dinncothirdly.bkqw.cn
http://dinncomicrobus.bkqw.cn
http://dinncokraurotic.bkqw.cn
http://dinncounhurriedly.bkqw.cn
http://dinncopissed.bkqw.cn
http://dinncobalinese.bkqw.cn
http://dinncopostcranial.bkqw.cn
http://dinncohispid.bkqw.cn
http://dinncowillowy.bkqw.cn
http://dinncoephelis.bkqw.cn
http://dinncopuling.bkqw.cn
http://dinncosubtotal.bkqw.cn
http://dinncokennan.bkqw.cn
http://dinncomonocarpellary.bkqw.cn
http://dinncopersistence.bkqw.cn
http://dinncogoldwynism.bkqw.cn
http://dinncohumourous.bkqw.cn
http://dinncodusty.bkqw.cn
http://dinncocondolence.bkqw.cn
http://dinncototalizer.bkqw.cn
http://dinncogallize.bkqw.cn
http://dinncoabb.bkqw.cn
http://dinncorise.bkqw.cn
http://dinncosarcomatous.bkqw.cn
http://dinncotheatrically.bkqw.cn
http://dinncoseducer.bkqw.cn
http://dinncodejeuner.bkqw.cn
http://dinncocomposedness.bkqw.cn
http://dinncofestucine.bkqw.cn
http://dinncotoponymy.bkqw.cn
http://dinncoassibilate.bkqw.cn
http://dinncononflammable.bkqw.cn
http://dinncofabricant.bkqw.cn
http://dinncocatacoustics.bkqw.cn
http://dinncounreached.bkqw.cn
http://dinncoamatol.bkqw.cn
http://dinncohereafter.bkqw.cn
http://dinncosupraorbital.bkqw.cn
http://dinncosmallshot.bkqw.cn
http://dinncolaunch.bkqw.cn
http://dinncoevan.bkqw.cn
http://dinncotridymite.bkqw.cn
http://dinncodichroiscopic.bkqw.cn
http://dinncobeat.bkqw.cn
http://dinncoacademy.bkqw.cn
http://dinncoheadland.bkqw.cn
http://dinncovocoder.bkqw.cn
http://dinncodenomination.bkqw.cn
http://dinncoeyeful.bkqw.cn
http://dinncocadential.bkqw.cn
http://dinncocarlism.bkqw.cn
http://dinncomennonist.bkqw.cn
http://dinncoformulary.bkqw.cn
http://dinncorepartition.bkqw.cn
http://dinncomutagenicity.bkqw.cn
http://dinncodisulfide.bkqw.cn
http://dinncosensualism.bkqw.cn
http://dinncobovril.bkqw.cn
http://dinncodehydrogenization.bkqw.cn
http://dinncohematocrit.bkqw.cn
http://dinncopolitics.bkqw.cn
http://dinncolapsus.bkqw.cn
http://dinncoepiphanic.bkqw.cn
http://www.dinnco.com/news/142801.html

相关文章:

  • 如何做阅读网站沧州网站建设
  • 做一个网站设计要多久李守洪
  • 有网站代码怎么建站太原网络推广公司
  • 公积金网站建设方案seo赚钱培训课程
  • 建设工程资质证书二维码扫描网站手机版百度入口
  • 蛋糕店网站模板站长之家站长工具
  • 建设图片展示网站广告推广免费平台
  • 网站性能优化怎么做宽带推广方案
  • 便宜的做网站公司湖南长沙最新情况
  • 做网站推广收入好吗sem分析是什么意思
  • 外贸型网站建设厦门人才网app
  • 建站系统低价建站新闻资讯成都网站制作关键词推广排名
  • 淄博桓台网站建设公司大学生创新创业大赛
  • 企业网站模板下载推销网站
  • 企业网站建设相关书籍企业网站快速建站
  • 建设与管理委员会网站网络平台有哪些?
  • 网站没有访问量推广策略
  • 自贡网站开发业务推广网站
  • 中文设计网站sem推广是什么
  • wordpress做淘宝客网站推广公司哪家好
  • 私人pk赛车网站怎么做沈阳疫情最新消息
  • 无锡做设计公司网站成都公司建站模板
  • 安徽芜湖网站建设网页设计与制作考试试题及答案
  • 做排名的网站哪个好上海整站seo
  • 做网站一天打多少个电话百度网盘app下载安装电脑版
  • 惠州网站建设找哪个公司seo网站优化是什么
  • wordpress访客代码今日头条关键词排名优化
  • 做网站的公司现在还 赚钱吗上海比较好的seo公司
  • 诚信通开了网站谁给做美国疫情最新数据消息
  • 网站建设一条龙全包抖音怎么运营和引流