如何在 Atmosphere 中浏览器连接关闭时销毁 BroadCaster
我在 tomcat 7.0.23 中使用气氛运行时创建了简单的服务器推送 我能够在浏览器中从服务器获取消息(数据),现在的问题是每当我关闭连接(浏览器)时,servlet 都会继续广播。我参考了大气白皮书。提到通过配置 CometConnectionManagerValve Valve 在 tomcat 7 中支持自动检测客户端远程断开 我已经这么做了。
<Engine> <Valve className="org.apache.catalina.valves.CometConnectionManagerValve"/><Engine>
但什么也没发生..这是我的 onStateChange 方法。
public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
throws IOException {
System.out.println("###############################ON STATE CHANGE#######################################");
System.out.println("BroadCaster Id : "+event.getResource().getBroadcaster().getID());
if(event.isCancelled()) {
System.out.println("Cancelled....");
event.getResource().getBroadcaster().destroy();
}
}
我还创建了 AtmosphereResourceEventListener 来跟踪各种事件。再次它没有调用任何方法..
请帮助。 提前致谢。
I have created simple server push using atmosphere run time in tomcat 7.0.23
I am able to get message(data) from server in browser, now the problem is whenever i am closing the connection(browser), the servlet keeps broadcasting. I have referred the atmosphere white paper. It's mention that Auto‐detect
client
remote
disconnection
is supported in tomcat 7 by configuring the
CometConnectionManagerValve
Valve
which i already did.
<Engine> <Valve className="org.apache.catalina.valves.CometConnectionManagerValve"/><Engine>
but nothing is happend.. Here is my onStateChange method.
public void onStateChange(AtmosphereResourceEvent<HttpServletRequest, HttpServletResponse> event)
throws IOException {
System.out.println("###############################ON STATE CHANGE#######################################");
System.out.println("BroadCaster Id : "+event.getResource().getBroadcaster().getID());
if(event.isCancelled()) {
System.out.println("Cancelled....");
event.getResource().getBroadcaster().destroy();
}
}
I have also created AtmosphereResourceEventListener to keep track of various event. again its not invoking any method..
Please help.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论