应用程序之间的本机消息传递是什么?它如何工作? [英] What is Native Messaging between applications and how does it work?

查看:156
本文介绍了应用程序之间的本机消息传递是什么?它如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Chrome开发者文档引用了称为Native Messaging的内容,以直接通过Chrome扩展程序或应用与其他桌面应用进行通信.

The Chrome developer docs refer to something called Native Messaging to communicate with other desktop applications directly from the Chrome extension or app.

如何判断桌面应用程序何时具有此类本机消息传递以及它可以接受哪种通信?有没有一种方法可以使应用程序公开其将要传达的信息?

How can I tell when a desktop app has such native messaging available and what kind of communication it can accept? Is there a way to get the application to expose what it will communicate about?

如果我需要与该桌面应用程序的原始开发人员交谈,这甚至是最常用的术语(本机消息传递),以便他们了解我的意思吗?

If I needed to talk to the original developers of that desktop app, is this even the most common terminology (native messaging) so they understand what I am referring to?

Windows和Mac上的本机消息传递功能是否相同?

Does native messaging function the same on both Windows and Mac?

推荐答案

扩展只能与本地桌面应用程序通信,前提是该应用程序已注册为本地消息传递主机".这意味着在预定义的,特定于平台的位置必须有一些清单文件,该文件声明该应用程序具有本机消息传递"功能,并且允许哪些扩展名与此本地消息传递主机进行通信.

An extension can only communicate with a native desktop application if that application is registered as a "native messaging host". This means that there must be some manifest file at a pre-defined, platform-specific location that declares that the application has "native messaging" capabilities and which extensions are allowed to communicate with this native messaging host.

因此,默认情况下,您的任何台式机应用程序都极有可能不太可能支持本机消息传递.该术语特定于Chrome/Chromium,不熟悉Chrome/Chromium的开发人员可能不会理解.尽管每个有能力的开发人员在阅读本机消息文档后,都应该能够使本机消息工作.

So, by default, it is extremely unlikely that any of your desktop apps support native messaging. This term is a specific to Chrome/Chromium, and might not be understood by developers who are not familiar with Chrome/Chromium. Though every competent developer should be able to get native messaging to work after reading the documentation of native messaging.

当前,与本机应用程序通信的唯一受支持方法是通过简单但严格的协议通过标准输入和输出管道(stdin/stdout).如果桌面应用程序具有命令行界面,那么您可以轻松地编写充当本机消息传递主机并与桌面应用程序进行交互的代理应用程序.本质上,它是您的Chrome扩展程序和某些其他应用程序之间的桥梁.可以使用任何支持stdin/stdout的语言编写此代理应用程序,并且不需要桌面应用程序原始开发人员的任何合作.

Currently, the only supported way of communicating with native applications is through the standard input and output pipes (stdin / stdout) via a simple yet strict protocol. If the desktop app has a command-line interface, then you can easily write a proxy application that serves as a native messaging host and interacts with the desktop application. It is essentially the bridge between your Chrome extension and some other application. This proxy application can be written in any language that supports stdin/stdout, and it does not require any cooperation from the original developers of the desktop app.

所有平台上的本机消息传递协议都是相同的,但是您必须考虑系统的字节顺序,并且清单文件的位置也取决于平台.

The native messaging protocol is the same across all platforms, but you have to take the endianness of the system into account, and the locations of the manifest file also platform-dependent.

这篇关于应用程序之间的本机消息传递是什么?它如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆