了解RProperty IPC通信
understanding RProperty IPC communication
我正在研究这个源库。基本上,这是Symbian第三版的Anim服务器客户端,目的是在不可靠的情况下获取输入事件。
如果你看到服务器的这一行,这里基本上是在设置RProperty值(显然是递增计数器);似乎没有对输入进行实际处理。
在这个客户端行中,客户端应该接收通知数据,但它只调用Attach。
我的理解是Attach只需要调用一次,但在客户端中不清楚每次服务器设置RProperty 时会触发什么事件
客户端应该如何(以及在哪里)访问RProperty值?
在Attach
之后,客户端将在Subscribe
的某个位置传递TRequestStatus
引用。当异步事件发生时(在您的情况下,属性已更改),服务器将通过内核发出请求状态属性的信号。如果示例源代码以正确的方式实现,您将发现一个活动对象(AO;CActive
派生类)挂在周围,并且该AO的iStatus
将传递给RProperty API。在这种情况下,属性发生更改时,将调用AO的RunL
函数。
在Symbian中,理解活动对象框架是至关重要的,而实际上很少有人这样做。不幸的是,我并没有在网上找到一个很好的描述(Symbian操作系统内部的书中对它们进行了很好的解释),但这个页面至少给了你一个快速的例子。
示例
在CActive
的CMyActive子类的ConstructL
中:
CKeyEventsClient* iClient;
RProperty iProperty;
// ...
void CMyActive::ConstructL()
{
RProcess myProcess;
TSecureId propertyCategory = myProcess.SecureId();
// avoid interference with other properties by defining the category
// as a secure ID of your process (perhaps it's the only allowed value)
TUint propertyKey = 1; // whatever you want
iClient = CKeyEventsClient::NewL(propertyCategory, propertyKey, ...);
iClient->OpenNotificationPropertyL(&iProperty);
// ...
CActiveScheduler::Add(this);
iProperty.Subscribe(iStatus);
SetActive();
}
属性更改后将调用您的RunL:
void CMyActive::RunL()
{
if (iStatus.Int() != KErrCancel) User::LeaveIfError(iStatus.Int());
// forward the error to RunError
// "To ensure that the subscriber does not miss updates, it should
// re-issue a subscription request before retrieving the current value
// and acting on it." (from docs)
iProperty.Subscribe(iStatus);
TInt value; // this type is passed to RProperty::Define() in the client
TInt err = iProperty.Get(value);
if (err != KErrNotFound) User::LeaveIfError(err);
SetActive();
}
相关文章:
- IPC使用多个管道和分支进程来运行Python程序
- VSOMEIP-2个设备之间的通信(TCP/UDP)不工作
- 是否可以使用winusb同时与多个相同的usb设备进行通信
- 混淆了如何使用IDL与Ethovision进行通信
- C++ Boost::asio串行通信与Arduino无法写入
- 我是否需要包含隐式使用/与 WindowsAPI 通信"Windows.h"?
- 通过TCP的PvP通信问题
- C++一个线程如何正确通信其任务已完成?
- 如何将 Firebase 与基于 Linux 的客户端应用配合使用,以便与服务器进行双向消息通信
- 我们可以通过 IPC 传递具有动态管理成员的类对象吗?
- 删除功能不适用于串行通信后多个循环中的多个实例
- 网站和C++程序在同一台 Linux PC 上的通信
- 通过插槽和信号在不同线程中的两个qt对象之间进行通信
- 使用 pybind11 共享 MPI 通信器
- 进程间通信堆内存
- 重复Handle()是否执行任何解释性通信(IPC),如果不是为什么目标参数
- 远程、IPC 和线程场景中微服务的低延迟通信
- 了解RProperty IPC通信
- C++与Python之间的通信(IPC)
- IPC: c++程序与一组bash脚本和c++程序的通信