是否可以让服务器向所有连接的客户端发送消息,而无需等待任何操作?让我解释一下:-)我一直在阅读docs/examples,我没有发现任何满足我需求的东西:流程总是一样的;一个客户端连接(例如:一个GET调用Rest API),连接是悬而未决的,直到接收到一个新的API调用(例如POST调用),服务器只是等待(至少这是我所理解的)。我的用例非常不同:我希望服务器在新数据可用时发送一些“通知”。这将是我的使用情况(很simplifed):Atmosphere Jersey - 服务器消息
- 客户端A连接到服务器
- 连接被暂停,因为没有新的数据可在瞬间
- 服务器得到通知,新的数据可以从一个外部 源,并将其广播到客户端A
- 转到步骤2
我所取得的成就迄今越来越成功建立连接。下一步是解决这个服务器问题。我必须说这项技术对我来说是全新的,所以我可能会误解某些事情是有效的。如果是这样的话,让我知道!
这是我的筹码:
- 春3.2.0发布
- 泽西1.8
- 气氛新泽西1.0.13
- 的Tomcat 7.0.40
谢谢大家提前!
UPDATE:以下this后,我得到这样的警告,我不知道如何摆脱:
2013-06-04 09:40:36,284 WARN [org.atmosphere.cpr.AtmosphereFramework] - Failed using comet support: org.atmosphere.container.Tomcat7AsyncSupportWithWebSocket, error: Tomcat failed to detect this is a Comet application because context.xml is missing or the Http11NioProtocol Connector is not enabled.
If that's not the case, you can also remove META-INF/context.xml and WEB-INF/lib/atmosphere-compat-tomcat.jar Is the Nio or Apr Connector enabled?
2013-06-04 09:40:36,285 WARN [org.atmosphere.cpr.AtmosphereFramework] - Using org.atmosphere.container.Tomcat7BIOSupportWithWebSocket
我跟着应用程序结构评论here,所以这不应该是一个问题。我已经注意到通过改变传输到“websocket”而不是“long-polling”显示没有错误。服务器终于发送数据困难:)