【问题标题】:How to use websockets into GWT如何在 GWT 中使用 websockets
【发布时间】:2014-05-07 15:19:10
【问题描述】:

我想在 GWT 中使用 websockets,在我使用异步回调之前,这是我之前如何工作的一个示例:

在包客户端中:

@RemoteServiceRelativePath("handler/categorieService")
 public interface CategorieServiceGwt extends RemoteService {

/**
 * Récupèrer la catégorie à travers l'identifiant passé en paramètre.
 * @param un identifiant de la catégorie.
 * @return la catégorie trouvée.
 */
CategorieModel getCategorieById(Long id) throws GwtRunTimeExceptionGwt;
}

异步接口: 公共接口 CategorieServiceGwtAsync {

/**
 * Récupèrer la catégorie à travers l'identifiant passé en paramètre.
 * @param un identifiant de la catégorie.
 * @return la catégorie trouvée.
 */
void getCategorieById(Long id, AsyncCallback<CategorieModel> callback);

}

在包服务器中实现 CategorieServiceGwt 接口:

public final class CategorieServiceGwtImpl implements CategorieServiceGwt {

private MapperDozerBean mapperDozerBean;

private CategorieService categorieService;

@Override
public CategorieModel getCategorieById(Long id) {
    return mapperDozerBean.map(categorieService.getCategorieById(id), CategorieModel.class);
}

所以我在互联网上看到了一些 websockets 的例子,但我不知道在这种情况下如何使用它?

【问题讨论】:

    标签: java html gwt websocket


    【解决方案1】:

    我建议通过本机绑定使用众所周知的 js 解决方案。 Websockets 和 comet 的问题最近才出现在您的项目中:我在 2011 年使用 GWT 库时遇到了不好的体验,其中连接关闭但我没有收到通知,无法重新连接等...

    我花了两个星期的时间来了解这个库,并发现很多东西必须重写。所以如果你知道一个好的 js/jQuery 库,我建议你使用那个

    【讨论】:

      【解决方案2】:

      “gwt websockets”在 Google 上的第一个结果是这个项目:

      https://code.google.com/p/gwt-ws/

      看看,也许它适合你。

      编码愉快!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-10-26
        • 2016-11-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-07-05
        • 1970-01-01
        相关资源
        最近更新 更多