Elemental2 is just the browsers API so pretty much any javascript example
will work. As a matter of fact, I always used to annoy/delight some of my
colleagues by taking an ES6 example and search replacing "const" with
"var", "let" with "var" and "=>" with "->" and you would be amazed how
often this produced workable code after a few autoimport fixes.
Anyhoo ... something like the following will work although I have not
compiled or tested this ... it is just a translation of a javascript
example ;).
final WebSocket socket = new WebSocket( "wss://echo.websocket.org/" );
socket.onopen = e -> {
DomGlobal.console.log( "[open] Connection established" );
socket.send( Global.JSON.stringify( JsPropertyMap.of( "message","Hi
ho Silver!" ) ) );
};
socket.onerror = e -> DomGlobal.console.log( "[error]", e );
socket.onmessage = e -> DomGlobal.console.log( "[message] Data
received from server: ", e.data );
socket.onclose = e -> {
if ( e.wasClean )
{
DomGlobal.console.log( "[close] Connection closed cleanly, code="
+ e.code + " reason=" + e.reason + "" );
}
else
{
// e.g. server process killed or network down
// event.code is usually 1006 in this case
DomGlobal.console.log( "[close] Connection died" );
}
};
On Mon, Oct 7, 2019 at 7:46 PM Frank <[email protected]> wrote:
> Do you know where I can find any documentation about how to use websockets
> with Elemental 2 ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "GWT Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-web-toolkit/0ec9d2a0-90df-4653-8cbc-8256d98b0948%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit/0ec9d2a0-90df-4653-8cbc-8256d98b0948%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Cheers,
Peter Donald
--
You received this message because you are subscribed to the Google Groups "GWT
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-web-toolkit/CACiKNc5P7mz9K1%2B%2BVYaaX78a%2BgY_-wNiWutr1s1sNY%3DSncmqjw%40mail.gmail.com.