简体   繁体   English

在java中将推送通知发送到桌面应用程序

[英]Sending Push Notification to Desktop application in java

Here is my application scenario...这是我的应用场景...

  1. User requests for login and sends credentials to the web server(From Desktop application using httpClient API).用户请求登录并将凭据发送到 Web 服务器(从使用 httpClient API 的桌面应用程序)。

  2. Servlet(tomcat) authenticates user and send valid or invalid user information. Servlet(tomcat) 对用户进行身份验证并发送有效或无效的用户信息。 If user is registered user, servlet will save IP address on the server.如果用户是注册用户,servlet 会在服务器上保存 IP 地址。

  3. Now I have to send some text to the user without getting another request(ie server push sort of technology).现在我必须在没有收到另一个请求的情况下向用户发送一些文本(即服务器推送技术)。 How can I accomplish this functionality and using what technology?我怎样才能完成这个功能并使用什么技术?

I would keep a connection to the server since the other solution requires that you implement a server that runs in the clients and that the clients have public IP addresses.我会保持与服务器的连接,因为其他解决方案要求您实现在客户端中运行的服务器并且客户端具有公共 IP 地址。

In chrome you can use background pages to keep the connection so that you can close the browser.在chrome中你可以使用后台页面来保持连接,这样你就可以关闭浏览器了。 Use desktop notifications from the background page.从后台页面使用桌面通知 Other browsers use other techniques.其他浏览器使用其他技术。 As a fallback you require the page to be open.作为后备,您需要打开该页面。

Now to the push.现在开始。 My favorite is to use web sockets .我最喜欢的是使用网络套接字 But there are several other techniques for this.但是还有其他几种技术可以做到这一点。 Comet is a good place to start if you need more info.如果您需要更多信息, Comet是一个很好的起点。

If still want to go for the other solution with a server component running at each client.如果仍然想使用在每个客户端上运行的服务器组件的其他解决方案。 You will have to implement a standalone client.您将必须实施一个独立的客户端。 Is this what you want?这是你想要的吗?

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

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