Maxii
Maxii

Reputation: 703

GWT Websockets Technology

I'm looking for a way to use websockets in GWT. There are some APIs but i heard that they don't work in developement mode. Is that right?

Upvotes: 0

Views: 2408

Answers (3)

Dmitriy Kuzkin
Dmitriy Kuzkin

Reputation: 459

This can be achieved with JSNI and stomp over sockjs

  1. ClientBundle with TextResource for this two javaScript.files

  2. Inject this TextResources as Script(don't miss setRemoveTag(false) as this is FromString)

    ScriptInjector.fromString(myRes.sockJs().getText()).setRemoveTag(false).inject();
    
  3. And establish a connection in JSNI

    var socket = new SockJs('myPath');
    var stompClient = Stomp.over(socket);
    var connect_callback = function() {.....}
    stompClient.connect({}, connect_callback)
    

You are able to return this stompClient as JavaScriptObject and later in jsni methods subscribe or send messages, or take a look at GWT JSNI Overlay functionality.

Upvotes: 0

midix
midix

Reputation: 121

I use Atmosphere and it works fine. You will find a chat for example in GWT.

Upvotes: 3

Suresh Atta
Suresh Atta

Reputation: 121998

Sounds like you are talking about Comet and Gwt-Ws.

To make them work you have to configure your Jetty server I mean to use JettyLauncher.

And the above frameworks supports in Webkit browsers like Chrome , Safari.

Upvotes: 1

Related Questions