有没有办法使用JavaScript发送CoAP命令? [英] Is there a way to send CoAP commands using JavaScript?

查看:125
本文介绍了有没有办法使用JavaScript发送CoAP命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道是否有办法在浏览器中发送CoAP查询(使用JavaScript?),但不使用node.js。

I was just wondering if there was a way to send CoAP queries in the browser (using JavaScript?), but not using node.js.

谢谢!

推荐答案

不幸的是,这不是直接可能的。出于安全原因,Web浏览器不为UDP套接字提供任何JavaScript API。

Unfortunately this is not directly possible. Web browsers do not provide any JavaScript API for UDP sockets for security reasons.

如果您需要浏览器内应用程序通过CoAP界面与设备通信,您可以需要提供中介服务。例如,您可以创建可通过HTTP访问的Web服务,并充当CoAP的转换程序。

If you need an in-browser app to communicate to a device via a CoAP interface, you may need to provide an intermediary service. For example, you could create a web service that is accessible via HTTP, and acts as a translator to CoAP.

请注意 node.js支持UDP连接,可用于发送CoAP消息。但是,它是服务器端技术,不能在浏览器中使用。它可以用来建立这样的翻译服务;但不是必需的。

Note that node.js does support UDP connections, and could be used to send CoAP messages. However, it is a server-side technology, and cannot be used in the browser. It could be used to build such a translator service; but would not be required.

此外,似乎Chrome Apps基于HTML5和JavaScript,但与网页截然不同,确实可以访问 UDP套接字

Also, it appears that "Chrome Apps", which are based on HTML5 and JavaScript, but are distinctly different from web pages, do have access to UDP Sockets.

这篇关于有没有办法使用JavaScript发送CoAP命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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