GWT Websockets与元素 [英] GWT Websockets with Elemental

查看:76
本文介绍了GWT Websockets与元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在GWT Web应用程序中使用websockets技术.

I would like to use websockets technology in a GWT web application.

我知道有一些使用Commet和Atmospere的实现,但是我想避免使用它们,因为它们实际上是对服务器的长期HTTP请求.

I know that there are some implementations using Commet and Atmospere, but i would like to avoid them as they are actually a long lived HTTP request to the server.

我有自己的Web套接字实现,我想知道是否有人知道客户端库或通过websocket实现我的客户端/服务器之间通信的方式.更具体地说,我听说GWT Elemental 包提供了这种功能.我对此进行了调查(搜索),但找不到任何具体的内容.

I have my own implementation of web sockets and i would like to know if someone knows a client side library or way that i can achieve to communicate between my client/server with websockets. More specifically, i heard that GWT Elemental package provides this kind of functionality. I researched (googled) about that but couldn't find anything specific.

有人可以指出我正确的方向吗?除 GWT Elemental 之外,任何其他建议都将受到欢迎.

Could someone point me to the right direction? Any suggestions except GWT Elemental are welcomed as well.

我发现了以下链接,即GWT-Elemental接口.我可以看到它是ReleaseCandidate版本,但我愿意尝试使用该功能.因此,如果有人在我想知道他/她的意见/建议之前使用过它.

I found out the below link, which is GWT-Elemental interface. I can see that it is a ReleaseCandidate version, but i would be willing to try using the functionality. So if anyone has used that before i would like to know his/her comments/suggestions.

推荐答案

我还没有使用Elemental中的Websockets,但是使用了FileReader API,它运行良好.
但是,您必须考虑Elemental是高度实验性的. 自Elemental库是自动生成的以来,Webkit的IDL中的某些规范已更改,因此无法使用.
因此,您可能需要找到解决方法,等等.

Well I haven't used Websockets from Elemental but the FileReader API and it worked fine.
However you have to take into account that Elemental is highly experimental. Some of the specifications in the IDL of Webkit have changed since the Elemental library was auto-generated and thus won't work.
So you might need to find workarounds, etc.

使用Elemental非常简单. 通常,您可以从包中使用BrowserWindow来获取要使用的类的实例. 像这样:

Working with Elemental is quite straightforward. You usually use Browser or Window from the package to get an instance of the class you want to work with. Something like this:

Window window = Browser.getWindow();
WebSocket webSocket =  window.newWebSocket(URL);
webSocket.setOnmessage(new EventListener() ....);
websocket.send();

这篇关于GWT Websockets与元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆