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

建设项目自主验收网站安阳百度

建设项目自主验收网站,安阳百度,江苏工程造价信息网,快递网站域名更换前言 Openharmony 3.1Release中存在消息通知的处理#xff0c;消息通知包括系统层事件发布、消息订阅、消息投递与处理#xff0c;为了开发者能够熟悉消息的处理流程#xff0c;本篇文章主要介绍系统层事件发布的相关流程。 整体流程 代码流程 发布消息 { eventAction)w…前言 Openharmony 3.1Release中存在消息通知的处理消息通知包括系统层事件发布、消息订阅、消息投递与处理为了开发者能够熟悉消息的处理流程本篇文章主要介绍系统层事件发布的相关流程。 整体流程 代码流程 发布消息 { eventAction)want.SetAction(usual.event.license.LIC_EXPIRED); EventFwk::CommonEventPublishInfo publishInfo;CommonEventData commonData;commonData.SetWant(want);if (!CommonEventManager::PublishCommonEvent(commonData, publishInfo)) {LICENSE_LOGI(failed to publish event[%{public}d], eventAction);return false;}return true;} CommonEventManager函数处理调用PublishCommonEvent {CommonEventPublishInfo publishInfo;return PublishCommonEventAsUser(data, publishInfo, nullptr, UNDEFINED_USER); } 调用PublishCommonEventAsUser const CommonEventPublishInfo publishInfo, const std::shared_ptrCommonEventSubscriber subscriber,const int32_t userId) {EVENT_LOGI(enter);return DelayedSingletonCommonEvent::GetInstance()-PublishCommonEventAsUser(data, publishInfo, subscriber,userId); } 调用CommonEvent的PublishCommonEventAsUser const std::shared_ptrCommonEventSubscriber subscriber, const int32_t userId) {EVENT_LOGI(enter);sptrIRemoteObject commonEventListener nullptr;if (!PublishParameterCheck(data, publishInfo, subscriber, commonEventListener)) {return false;}EVENT_LOGD(before PublishCommonEvent proxy valid state is %{public}d, isProxyValid_);return commonEventProxy_-PublishCommonEvent(data, publishInfo, commonEventListener, userId); } CommonEventProxy调用PublishCommonEvent向服务端发送CES_PUBLISH_COMMON_EVENT消息 const sptrIRemoteObject commonEventListener, const int32_t userId) {EVENT_LOGD(start);MessageParcel data;MessageParcel reply;…….bool ret SendRequest(ICommonEvent::Message::CES_PUBLISH_COMMON_EVENT, data, reply);if (ret) {ret reply.ReadBool();}EVENT_LOGD(end);return ret; } 服务端接收CES_PUBLISH_COMMON_EVENT消息 {if (data.ReadInterfaceToken() ! GetDescriptor()) {EVENT_LOGE(local descriptor is not equal to remote);return ERR_TRANSACTION_FAILED;}switch (code) {case static_castuint32_t(ICommonEvent::Message::CES_PUBLISH_COMMON_EVENT): {std::unique_ptrCommonEventData event(data.ReadParcelableCommonEventData());std::unique_ptrCommonEventPublishInfo publishinfo(data.ReadParcelableCommonEventPublishInfo());sptrIRemoteObject commonEventListener nullptr;bool hasLastSubscriber data.ReadBool();if (hasLastSubscriber) {sptrIRemoteObject commonEventListener data.ReadRemoteObject();}int32_t userId data.ReadInt32();if (!event) {EVENT_LOGE(Failed to ReadParcelableCommonEventData);return ERR_INVALID_VALUE;}if (!publishinfo) {EVENT_LOGE(Failed to ReadParcelableCommonEventPublishInfo);return ERR_INVALID_VALUE;}bool ret PublishCommonEvent(*event, *publishinfo, commonEventListener, userId);if (!reply.WriteBool(ret)) {EVENT_LOGE(Failed to write reply );return ERR_INVALID_VALUE;}break;}……..default:EVENT_LOGW(unknown, code %{public}u, flags %{public}u, code, option.GetFlags());return IPCObjectStub::OnRemoteRequest(code, data, reply, option);}return NO_ERROR; } 调用服务端PublishCommonEvent函数 const CommonEventPublishInfo publishinfo, const sptrIRemoteObject commonEventListener, const int32_t userId) {EVENT_LOGI(enter);if (!IsReady()) {return false;}return PublishCommonEventDetailed(event, publishinfo, commonEventListener, IPCSkeleton::GetCallingPid(),IPCSkeleton::GetCallingUid(),userId); } PublishCommonEventDetailed绑定PublishCommonEvent,然后进行事件投递 const CommonEventPublishInfo publishinfo, const sptrIRemoteObject commonEventListener, const pid_t pid,const uid_t uid, const int32_t userId) {EVENT_LOGI(enter);struct tm recordTime {0};if (!GetSystemCurrentTime(recordTime)) {EVENT_LOGE(Failed to GetSystemCurrentTime);return false;}std::string bundleName DelayedSingletonBundleManagerHelper::GetInstance()-GetBundleName(uid);if (DelayedSingletonPublishManager::GetInstance()-CheckIsFloodAttack(uid)) {EVENT_LOGE(Too many common events have been sent in a short period from %{public}s (pid %{public}d, uid %{public}d, userId %{public}d), bundleName.c_str(), pid, uid, userId);return false;}Security::AccessToken::AccessTokenID callerToken IPCSkeleton::GetCallingTokenID();std::functionvoid() PublishCommonEventFunc std::bind(InnerCommonEventManager::PublishCommonEvent,innerCommonEventManager_, event, publishinfo, commonEventListener, recordTime, pid,uid, callerToken, userId, bundleName, this);return handler_-PostTask(PublishCommonEventFunc); } 在事件投递中调用处理InnerCommonEventManager::PublishCommonEvent const sptrIRemoteObject commonEventListener, const struct tm recordTime, const pid_t pid, const uid_t uid,const Security::AccessToken::AccessTokenID callerToken, const int32_t userId, const std::string bundleName,const sptrIRemoteObject service) {EVENT_LOGI(enter %{public}s(pid %{public}d, uid %{public}d), event %{public}s to userId %{public}d,bundleName.c_str(), pid, uid, data.GetWant().GetAction().c_str(), userId);if (data.GetWant().GetAction().empty()) {EVENT_LOGE(the commonEventdata action is null);return false;}if ((!publishInfo.IsOrdered()) (commonEventListener ! nullptr)) {EVENT_LOGE(When publishing unordered events, the subscriber object is not required.);return false;}std::string action data.GetWant().GetAction();bool isSystemEvent DelayedSingletonCommonEventSupport::GetInstance()-IsSystemEvent(action);…….if (!controlPtr_) {EVENT_LOGE(CommonEventControlManager ptr is nullptr);return false;}controlPtr_-PublishCommonEvent(eventRecord, commonEventListener);…….return true; } 默认IsOrdered是false参数不配置调用ProcessUnorderedEvent const CommonEventRecord eventRecord, const sptrIRemoteObject commonEventListener) {EVENT_LOGI(enter);bool ret false;if (!eventRecord.publishInfo-IsOrdered()) {ret ProcessUnorderedEvent(eventRecord);} else {ret ProcessOrderedEvent(eventRecord, commonEventListener);}return ret; } 无序事件处理投递事件在hander中调用NotifyUnorderedEvent const CommonEventRecord eventRecord, const std::shared_ptrEventSubscriberRecord subscriberRecord) {…….std::functionvoid() innerCallback std::bind(CommonEventControlManager::NotifyUnorderedEvent, this, eventRecordPtr);if (eventRecord.isSystemEvent) {ret handler_-PostImmediateTask(innerCallback);} else {ret handler_-PostTask(innerCallback);}return ret; } NotifyUnorderedEvent调用NotifyEvent {……for (auto vec : eventRecord-receivers) {size_t index eventRecord-nextReceiver;eventRecord-curReceiver vec-commonEventListener;if (vec-isFreeze) {eventRecord-deliveryState[index] OrderedEventRecord::SKIPPED;DelayedSingletonCommonEventSubscriberManager::GetInstance()-InsertFrozenEvents(vec, *eventRecord);} else {……if (ret OrderedEventRecord::DELIVERED) {eventRecord-state OrderedEventRecord::RECEIVEING;commonEventListenerProxy-NotifyEvent(*(eventRecord-commonEventData), false, eventRecord-publishInfo-IsSticky());eventRecord-state OrderedEventRecord::RECEIVED;}}}…… } 在EventReceiveProxy::NotifyEvent函数中发送消息CES_NOTIFY_COMMON_EVENT {……int32_t result remote-SendRequest(static_castuint32_t(IEventReceive::Message::CES_NOTIFY_COMMON_EVENT), data, reply, option);if (result ! OHOS::NO_ERROR) {EVENT_LOGE(Failed to SendRequest, error code: %{public}d, result);return;}EVENT_LOGD(end); } 服务端接收消息调用服务端NotifyEvent函数 {if (data.ReadInterfaceToken() ! GetDescriptor()) {EVENT_LOGE(local descriptor is not equal to remote);return ERR_TRANSACTION_FAILED;}switch (code) {case static_castuint32_t(IEventReceive::Message::CES_NOTIFY_COMMON_EVENT): {std::unique_ptrCommonEventData eventData(data.ReadParcelableCommonEventData());bool ordered data.ReadBool();bool sticky data.ReadBool();if (eventData nullptr) {EVENT_LOGE(callback stub receive common event data is nullptr);return ERR_INVALID_VALUE;}NotifyEvent(*eventData, ordered, sticky);break;}default:EVENT_LOGW(event receive stub receives unknown code, code %{public}u, code);return IPCObjectStub::OnRemoteRequest(code, data, reply, option);}return NO_ERROR; } 服务端NotifyEvent函数调用OnReceiveEvent {EVENT_LOGI(enter);std::lock_guardstd::mutex lock(mutex_);if (!IsReady()) {EVENT_LOGE(not ready);return;}std::functionvoid() onReceiveEventFunc std::bind(CommonEventListener::OnReceiveEvent, this, commonEventData, ordered, sticky);handler_-PostTask(onReceiveEventFunc); } 从上面我们就梳理整个系统层事件发布流程希望对大家有所帮助。
http://www.dnsts.com.cn/news/53101.html

相关文章:

  • 密云成都网站建设app制作平台收费标准
  • 网站备案域名用二级域名响应式网站解决方案
  • 咖啡网站设计建设帝国cms资源网模板
  • 禹顺生态建设有限公司网站怎样看网站是谁做的
  • 用ps做网站网页地推拉新接单网
  • 年报是否就是在工商网站做的手机画户型图的软件
  • 鹤山区网站建设建网站与建网页的区别
  • 小的电商网站网页源代码里哪个是视频链接
  • 平台网站模板素材做全景图的网站
  • 阿里巴巴网站建设规划海南网站建设及维护
  • html5国外网站模板html源码下载洛阳理工学院教务管理系统
  • 深圳网站建设新闻网站建设公司简介模板
  • 怎样打造营销型网站建设湘潭天元建设集团有限公司董事长
  • 网站策划书 范文导航网站分析
  • 有经验的常州网站建设做网站和做商城的区别在哪里
  • 网站建设的背景有哪些站长工具是做什么的
  • 大连网站建设哪个公司好设计网站费用多少
  • 集团网站建设方案深圳的产品设计公司
  • 正在建设中的网站旺店通app手机企业版下载
  • 盐山网站建设价格抖音小程序怎么开通
  • 顺德网站建设找顺的泰安吧贴吧
  • 网站风格的表现形式北京网站开发需要多少钱
  • 耒阳市网站建设什么主题的网站容易做点
  • 河北智能网站建设黄埔网站开发公司
  • 济宁网站网站建设网站建设昆山花桥
  • 宁波网站建设公司推荐易企网宜昌营销型网站建设
  • 便宜建站vpswordpress国内备份神器
  • 物流推广做哪个网站2023二级建造师报名官网入口
  • windows10网站建设如何做企业网络营销推广
  • 做网站的步骤是什么高校网站建设制度