Coder Social home page Coder Social logo

gwt-websockets's Introduction

Deprecated

This project has been deprecated in favour of the WebSocket support provided by Elemental2. Elemental2 is closer to the browser, future compatible and easier to maintain.


gwt-websockets

Build Status

A simple library to provide web sockets support to GWT.

Quick Start

The simplest way to use the library is to add the following dependency into the build system. i.e.

<dependency>
   <groupId>org.realityforge.gwt.websockets</groupId>
   <artifactId>gwt-websockets</artifactId>
   <version>1.2</version>
   <scope>provided</scope>
</dependency>

Then you add the following snippet into the .gwt.xml file.

<module rename-to='myapp'>
  ...

  <!-- Enable the websocket library -->
  <inherits name="org.realityforge.gwt.websockets.WebSockets"/>
</module>

Then you can interact with the WebSocket from within the browser.

final WebSocket webSocket = WebSocket.newWebSocketIfSupported();
if ( null != webSocket )
{
  webSocket.setListener( new WebSocketListenerAdapter()
  {
    @Override
    public void onOpen( final WebSocket webSocket )
    {
      // After we have connected we can send
      webSocket.send( "Hello!" );
    }

    @Override
    public void onMessage( final WebSocket webSocket, final String data )
    {
      // After we receive a message back we can close the socket
      webSocket.close();
    }
  } );
  webSocket.connect( "ws://localhost/ws/echo" );
}

This should be sufficient to put together a simple WebSocket application.

A very simple example of this code is available in the gwt-websockets-example project.

TODO

  • Consider supporting a Blob object from the HTML5 File API with send and receive.

Appendix

gwt-websockets's People

Contributors

realityforge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.