五 Example 3: Connections to Remote Nodes using a Registry

2024-06-20 07:38

本文主要是介绍五 Example 3: Connections to Remote Nodes using a Registry,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

QRemoteObjectRegistry类有什么用?可以参考下图:
在这里插入图片描述
在某些应用程序中,需要有多个源,而为每个副本分别连接到每个源则显得很冗余,因此QRemoteObjectRegistryHost的任务是为多个源提供一个连接点,并通过它连接每个副本。

QRemoteObjectRegistry类型的registry属性。而它有两个关键信号:

void remoteObjectAdded(const QRemoteObjectSourceLocation &entry);
void remoteObjectRemoved(const QRemoteObjectSourceLocation &entry);

当带有Registry的QtRO网络中有新的Source被enableRemoting出来,则每个接入的Node的registry属性都会发出remoteObjectAdded这个信号;当有Source被disableRemoting之后,每个接入的Node的registry都会发出remoteObjectRemoved信号。

Source 端代码

simpleswitch.h 和 simpleswitch.cpp 不做修改, 不同之处在于主机节点的创建和连接方式:
main.cpp

  #include <QCoreApplication>#include "simpleswitch.h"int main(int argc, char *argv[]){QCoreApplication a(argc, argv);SimpleSwitch srcSwitch; // create SimpleSwitchQRemoteObjectRegistryHost regNode(QUrl(QStringLiteral("local:registry"))); // create node that hosts registryQRemoteObjectHost srcNode(QUrl(QStringLiteral("local:switch")), QUrl(QStringLiteral("local:registry"))); // create node that will host source and connect to registry//Note, you can add srcSwitch directly to regNode if desired.//We use two Nodes here, as the regNode could easily be in a third process.srcNode.enableRemoting(&srcSwitch); // enable remoting of source objectreturn a.exec();}

Replica 端代码

本例中使用的请求者对象是示例2中讨论的动态副本客户端。

唯一的修改是主要的。cpp:创建注册表节点以获取副本:

QRemoteObjectNode repNode(QUrl(QStringLiteral("local:registry")));

可参考https://zhuanlan.zhihu.com/p/68383336

这篇关于五 Example 3: Connections to Remote Nodes using a Registry的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1077512

相关文章

BD错误集锦1——[Hive]ERROR StatusLogger No log4j2 configuration file found. Using default configuration:

错误描述:在使用IDEA进行jdbc方式连接到hive数据仓库时,出现以下错误:                ERROR StatusLogger No log4j2 configuration file found. 问题原因:缺少log4j2.xml文件   <?xml version="1.0" encoding="UTF-8"?><Configuration><Appender

VMWARE 安装失败 “FAILED TO CREATE THE REQUESTED REGISTRY KEY KEY

问题详情: 安装虚拟机VMWare Workstation8.0时出现“failed to create the requested registry key key installer error 1021” 解决问题: 1.在注册表(开始--运行[win+R]--输入regedit)中找到HKEY_LOCAL_MACHINE\SOFTWARE\VMware, Inc. 将V

论文阅读--Efficient Hybrid Zoom using Camera Fusion on Mobile Phones

这是谷歌影像团队 2023 年发表在 Siggraph Asia 上的一篇文章,主要介绍的是利用多摄融合的思路进行变焦。 单反相机因为卓越的硬件性能,可以非常方便的实现光学变焦。不过目前的智能手机,受制于物理空间的限制,还不能做到像单反一样的光学变焦。目前主流的智能手机,都是采用多摄的设计,一般来说一个主摄搭配一个长焦,为了实现主摄与长焦之间的变焦,目前都是采用数字变焦的方式,数字变焦相比于光学

在WinCE的C#编程中,需要静态调用C++的动态库,需要添加using System.Runtime.InteropServices

using System.Runtime.InteropServices;         [DllImport("Win32DLL.dll", EntryPoint = "WriteREG_SZToRegTCHAR")]         private static extern bool WriteREG_SZToRegTCHAR(int iFlag, string regKeyP

[Dubbo] connections 参数

一、用途 为某个接口创建独立的连接通道,若未配置该参数,则共享一个连接通道。 二、配置方式 消费者: <dubbo:reference protocol="dubbo" id="demoApi" version="${dubbo.service.version}"interface="com.wlm.demoApi" check="false" timeout="2000" connect

Registry仓库Harbor的部署与简介

Harbor 是Vmware公司开源的企业级DockerRegistry管理项目,开源项目地址:https://github.com/vmware/harbor。Harbor的所有组件都在Docker中部署,所以Harbor可使用Docker Compose快速部署。(由于Harbor是基于Docker Registry V2版本,所以docker版本至少1.10.0、docker-compos

Git报错git: ‘remote-http‘ is not a git command. See ‘git --help‘

目录 一、问题描述二、解决方法 一、问题描述 CentOS 7 下执行 git clone http://xxxx 命令时报错,Git 版本为 2.35.1 : git: 'remote-http' is not a git command. See 'git --help' 二、解决方法 安装 libcurl-devel、curl-devel ,然后重新编译 git

java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)问题

1.问题描述:   在myeclipse中发布web服务器,通过手机客户端访问MySQL数据库(也就是myeclipse中的tomcat连接的数据库),myEclipse 的控制台(Console)报出如下错误 java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES) 2.自己

Git中push时出现错误fatal: The remote end hung up unexpectedly

错误如下:fatal: The remote end hung up unexpectedly 原因:传输文件太大 解决办法: windows: 在 .git/config 文件中加入 [http] postBuffer = 524288000 linux: git config http.postBuffer 524288000

git push.default Update were rejected because a pushed branch tip is behand remote

现象:可以git pull下来,然后再git status,显示正常。 通过浏览器访问git地址,发现没有别人提交的修改,最新修改是自己提交的。 咨询同事,给出一个命令,就搞定可以正常push了。 git config --global push.default current 这句命令什么意思呢?指定push 的模式是current ,仅仅push 当前分支(这个分支名和远程分支名相同