java - 将警报推送到 Java 中的通知托盘应用程序

标签 java wcf api comet push

如何在不使用 xmpp 或其他重型协议(protocol)的情况下将服务器警报推送到 java 中的托盘应用程序?

您是否推荐一种方法来实现这一点?

我计划编写一个在配备 Comet 的服务器上使用 URLConnection 的应用程序,但我怀疑这是否可行,因为客户端需要调用 JS 而 URLConnection 不是浏览器..

什么是最好的推送方式而不是使用专有的客户端-服务器方法?

最佳答案

我使用 Growl在我的 Mac 上接收来 self 的应用程序的本地通知,但您也可以发送 Growl 远程通知。还有一个 Windows version , 以及 Java library可用的。这是示例 Java 代码(需要 Java 6):

// give your application a name and icon (optionally)
Application serverApp = new Application("Server App");

// create reusable notification types, their names are used in the Growl settings
NotificationType start = new NotificationType("ServerStart");
NotificationType shutdown = new NotificationType("ServerShutdown");
NotificationType[] notificationTypes = new NotificationType[] {start, shutdown};

// connect to Growl on the given host
GrowlConnector growl = new GrowlConnector("localhost");

// now register the application in growl
growl.register(serverApp, notificationTypes);

// finally send the notification
growl.notify(new Notification(serverApp, start, "Server is starting", "Good luck"));

关于java - 将警报推送到 Java 中的通知托盘应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2925426/

相关文章:

java - 如何从 Java EE Web 应用程序运行外部应用程序?

Java 替换 xml 中的单词

java - 在Java中使用RSA公钥文件加密AES key

java - import com.wordnik 无法解析

c# - 模拟对象仍在调用服务

c# - 我需要做什么才能在 WCF 服务中使用 System.Windows.Forms.WebBrowser 控件?

node.js - 无法从React应用程序进行 Node API调用

java - 折线未清除

javascript - 由于语法无效,服务器无法处理 PUT 请求 (ASP.NET)

c# - 此 WCF 配置是否导致我的 400 错误请求?