0
我试着开发一个小的gwt聊天应用程序Atmosphere的gwt扩展。应用程序的服务器端部分注意传入的AtmosphereResource关联广播器并暂停它。 这里是关于暂停新的传入AtmosphereResource代码片段:AtmosphereResource变为空
private void doGet(AtmosphereResource ar, String userId) {
if(BroadcasterFactory.getDefault().lookup(userId) != null) {
ar.setBroadcaster(BroadcasterFactory.getDefault().lookup(userId).addAtmosphereResource(ar));
} else {
ar.setBroadcaster(BroadcasterFactory.getDefault().get(userId).addAtmosphereResource(ar));
}
ar.suspend();
...
}
当我寻找那些AtmosphereResource,使用它以前存储的UUID,我一直觉得很空:
...
AtmosphereResource arTarget = AtmosphereResourceFactory.getDefault().find(uuid);
if (arTarget != null) {
arTarget.getBroadcaster().broadcast(msg,arTarget);
} else {
log.info("handleRawMessage:no broadcaster "+((RawMessage) msg).toString());
}
...
有什么不对?我还注意到,AtmosphereResources在立即超时时迅速获得了onResume,但超时设置为-1。我错过了什么?这是我pom的一个片段。
<dependency>
<groupId>org.atmosphere.extensions</groupId>
<artifactId>atmosphere-gwt20-client</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.atmosphere.extensions</groupId>
<artifactId>atmosphere-gwt20-common</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.atmosphere.extensions</groupId>
<artifactId>atmosphere-gwt20-server</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.atmosphere</groupId>
<artifactId>atmosphere-runtime</artifactId>
<version>2.1.1</version>
</dependency>
您好!感谢您的回复。为什么你为服务器端实现了AtmosphereGWTHandler的扩展?我使用AbstractReflectorAtmosphereHandler实现我的服务器端。您是否将这个扩展名作为氛围处理程序指向您的atmosphere.xml文件? – Francesco
是的,我使用旧版本,我意识到之后,为什么我编辑我的答案,把我使用的气氛版本。现在我正在尝试2.0。我现在告诉你,如果它也在工作;) – Kasas
我已经测试了气氛2.0,我可以找到没有问题的广播公司。你确定你有一个客户端连接?我会发布我的代码。 – Kasas