简体   繁体   English

在浏览器应用程序和.net Windows应用程序之间进行通信

[英]Communicate between a browser application and .net Windows application

The requirement is to provide duplex communication methodology between .net client application which is a windows application and javascript application, which runs on the browser. 要求是在.net客户端应用程序和Windows应用程序之间提供双工通信方法,该应用程序是在浏览器上运行的。

Flow is 1. User installs the client app on their machine. 流程为1.用户在其计算机上安装客户端应用程序。 2. User visits the website and logs in to the portal which hosts the javascript app. 2.用户访问网站并登录到托管javascript应用程序的门户网站。 3. If the user performs an activity on client .net app, javascript app requires to be notified. 3.如果用户在客户端.net应用程序上执行活动,则需要通知javascript应用程序。 4. If the user performs an activity on the javascript app on the browser the .net client application has to be notified. 4.如果用户在浏览器上的javascript应用程序上执行活动,则必须通知.net客户端应用程序。

Possible solutions tried out are 1. Web server .net client app, where javascript app connects to using web sockets. 尝试的可能解决方案是1. Web服务器.net客户端应用程序,其中javascript应用程序连接到使用Web套接字。 However given the .net client app might start the webserver on a different port than originally intended, if the ports in use, the javascript app might not be able to identify the port the web server is running on. 但是,如果.net客户端应用程序可能在不同于最初预期的端口上启动Web服务器,如果使用的端口,javascript应用程序可能无法识别Web服务器正在运行的端口。 2. Have an activeX running on the javacript app. 2.在javacript应用程序上运行activeX。 Both the active X and .net app will connect through local named pipes through WCF. 活动X和.net应用程序都将通过WCF连接本地命名管道。 Bad part is use of active X will show a pop up soon as you load the web application. 不好的部分是使用活动X将在加载Web应用程序时显示弹出窗口。

Would you know of a better solution for the problem? 你知道更好的解决方案吗?

We've successfully used WebSockets for duplex communications between in-browser Javascript and an external app running a WebSocket server. 我们已成功使用WebSockets在浏览器内Javascript和运行WebSocket服务器的外部应用程序之间进行双工通信。 It's efficient and (at least as of last year) bypassed all browser sandbox restrictions. 这是有效的(至少截至去年)绕过了所有浏览器沙箱限制。 I'm not 100% understanding this part of your question: 我不是100%理解你问题的这一部分:

However given the .net client app might start the webserver on a different port than originally intended, if the ports in use, the javascript app might not be able to identify the port the web server is running on 但是,如果.net客户端应用程序可能在不同于预期的端口上启动Web服务器,如果使用的端口,javascript应用程序可能无法识别Web服务器正在运行的端口

The .NET app can run a socket server on any port it wants. .NET应用程序可以在任何所需的端口上运行套接字服务器。 If you are writing both apps, I'm not seeing how synchronizing on a specific port would be an issue? 如果您正在编写这两个应用程序,我没有看到如何在特定端口上进行同步会出现问题? Worst case scenario the desktop app could write the port to local storage, which your JS can grab via local storage. 最糟糕的情况是,桌面应用程序可以将端口写入本地存储,您的JS可以通过本地存储获取。 There are other ways to synch this as well. 还有其他方法可以同步这个。

SignalR is a communications API that has client libraries for both .NET and javascript, and the server library is built on the ASP.NET stack. SignalR是一个通信API,具有.NET和javascript的客户端库,服务器库构建在ASP.NET堆栈上。

With it, you can build a solution that allows client (js) <-> server <-> client (.NET) communication. 有了它,您可以构建一个允许client (js) <-> server <-> client (.NET)通信的解决方案。

Here are some useful links to get you started: 以下是一些有用的链接,可帮助您入门:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM