【发布时间】: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 的例子,但我不知道在这种情况下如何使用它?
【问题讨论】: