Firebreath 中的 IPC(升压 c++)
我需要使用 Boost 将字符串从一个进程发送到另一个进程。实际上我正在尝试创建一个 firebreath 插件(firebreath 在其后端使用 Boost)它应该能够向另一个 firebreath 插件发送消息。我认为应该是某种事件机制;当发送者插件发送字符串时,应该在接收者插件中触发一个事件。最好的方法是什么?
I need to send a string from one process to another using Boost. Actually I'm trying to create a firebreath plug-in (firebreath uses Boost in its backend) which should be capable of sending messages to another firebreath plugin. I think it should be some event mechanism; when the sender plugin sends the string, an event should be fired in the receiver plugin. What is the best way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有些人建议使用 boost::ipc,其他人则警告说 boost::ipc 在 Windows 上运行不佳。我自己没有尝试过 boost::ipc ,所以我不知道。一种选择是使用 boost::asio 创建本地套接字(本地主机上的套接字)并启动一个线程在一侧侦听; Windows 上的另一个选择是使用命名管道。我过去使用命名管道并取得了很好的成功。
要记住的主要事情是,您不能阻止 FireBreath 中的主线程 - 如果您这样做,它将锁定浏览器进程,或者最好的情况会导致弹出一个对话框,询问用户是否要终止您的插件。相反,创建第二个线程来处理侦听器,然后在页面需要了解的情况发生时调用 FireEvent。
另请参阅Boost IPC 有什么好处吗?
some have suggested using boost::ipc, others have warned that boost::ipc doesn't work well on windows. I haven't tried boost::ipc myself, so I don't know. One option would be to use boost::asio to create a local socket (socket on localhost) and start a thread to listen on one side; another option on windows would be to use named pipes. I've used named pipes with good success in the past.
The main thing to remember is that you can't block the main thread in FireBreath -- if you do it'll lock up the browser process or best case cause a dialog to pop up asking the user if they want to kill your plugin. Instead, create a second thread to handle the listener and then call FireEvent when something happens that your page needs to know about.
See also Is Boost IPC any good?