Web 应用程序的客户端浏览器套接字通信 - 最佳方法?
抱歉这个神秘的标题,很难用一行来概括我的问题...
我希望部署一个在线托管网站来为一系列远程终端提供服务,这些终端将配备芯片和芯片。密码支付卡读卡器(又名密码键盘)。密码键盘由终端内 PC 上的一些软件驱动,该软件由第三方编写。该软件支持的集成方法是基于文本文件或基于套接字的“请求”和“响应”工作流程。
我过去曾使用客户端 VB 脚本实例化客户端 COM 对象,这些对象通过套接字连接与本地第 3 方软件进行通信,但这种方法将我与 Windows 联系在一起,我更愿意保留我的选项,成功地进行了类似的集成。
我的 Web 服务器将基于 Ruby On Rails,我打算使用 HTML5 和 CSS3 在支付终端上提供丰富的体验,并且想知道我是否可以使用 Web 套接字进行客户端通信?据我了解,这不是它们的设计目的,所以我认为答案是否定的。
那么,我有什么选择呢?我可以使用客户端 JavaScript 进行套接字通信吗?或者浏览器安全措施会阻止这种情况发生吗?从浏览器的角度来看,它将与“localhost”上的特定编号端口进行通信。
如果无法进行套接字通信,我可以使用 JavaScript 创建客户端文本文件来以这种方式集成吗?
或者我是否受困于 VB 脚本和本地 COM 对象?
我们非常欢迎任何建议,如果您需要澄清我的问题的任何方面,请告诉我。
亲切的问候, 克雷格.
Sorry for the cryptic title, struggling to summarise my problem in a single line...
I wish to deploy an online, hosted website to serve a series of remote terminals which will be equipped with Chip & Pin payment card readers (aka pinpads). The pinpads are driven by some software on the PC within the terminal which is written by a 3rd party. The integration methods supported by this software are either text file based or socket based with a "request" and "response" workflow.
I have successfully carried out similar integrations in the past using client side VB Script to instantiate client side COM objects which communicate via socket connection with the local 3rd party software but this approach ties me to Windows and I would prefer to keep my options open.
My web server will be Ruby On Rails based and I intend to use HTML5 and CSS3 to provide a rich experience on the payment terminals and wondered if I can use web sockets for client side communications? From what I understand, this is not what they are designed for and so I think the answer is no.
So, what are my options? Can i use client side JavaScript to carry out socket communications or is this prevented by browser security measures? From the browser's perspective it would be communicating with a specific numbered port on "localhost"
If socket comms is not possible, can I use JavaScript to create client side text files to integrate that way?
Or am I stuck with VB script and local COM objects?
Any suggestions would be most welcome and please let me know if you need clarification on any aspect of my question.
Kind regards,
Craig.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你不能用 JavaScript 编写文本文件。而且你也不能在套接字上放置任意字节。我不完全理解你的场景。听起来您在服务器上运行了 Ruby,在客户端上运行了 JavaScript 和第三方密码键盘。您需要两个客户端实体能够相互通信。您能否让浏览器与您的 Ruby 服务器通信(使用多种 Web 技术之一),然后让您的 Ruby 服务器将数据转发回 pinpad 套接字。或者密码键盘只是本地插座?
I don't think you can write a text file with JavaScript. And you can't put arbitrary bytes on a socket either. I don't completely understand you scenario. It sounds like you have Ruby sunning on a server and JavaScript and this third party pinpad thing running on a client. And you need the two client entities to be able to talk to each other. Could you have the browser communicate with your Ruby server (using one of many web technologies) and then have your Ruby server relay the data back to the pinpad socket. Or is the pinpad only a local socket?
允许您在运行 javascript 的标准网页上打开的唯一基于套接字的连接类型是 HTTP 套接字。如果您开发一个用 javascript 编写的浏览器插件,您将有更多的自由来使用套接字。据我所知,Firefox 在扩展中支持套接字。
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsISocketProvider
The only type of socket-based connection you are allowed to open on a standard web page that runs javascript is an HTTP socket. You'll have a lot more freedom to use sockets if you develop a browser plugin, which is written in javascript. Firefox, I know, supports sockets in extensions.
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsISocketProvider