1

实际上我会从@ManagedService 路径中检索两个参数,但我只得到空值。代码类似于:

...
import org.atmosphere.config.service.PathParam;
import org.atmosphere.config.service.ManagedService;
import org.atmosphere.config.service.Singleton;

@Singleton
@ManagedService(path = "/chat/{myId}/{destId}")
public class Chat {

  @PathParam("myId")
  private String mittId;

  @PathParam("destId")
  private String destId;

  @Ready
  public void onReady(AtmosphereResource r) {
    logger.info("User {} want to chat with {}", mittId,destId);
  }

调试“mittId”和“destId”为空。代码有错误或我忘记了什么?实际上我使用的是 Atmosphere-runtime 2.3.0。

感谢任何会提供帮助的人!

4

2 回答 2

1

客户端是正确的。我解决了删除 @Singleton 注释。现在,当我调试时,我可以看到两个参数的值。

于 2016-01-05T10:14:40.220 回答
0

要么您没有共享足够多的原始后端代码,要么您的客户端应用程序错误地调用了聊天资源。

我测试了您的示例,并且填充了两个路径参数。请查看 Atmosphere Github 页面中关于聊天室的示例,尤其是客户端实现。

于 2016-01-05T09:53:03.070 回答