Implementing WebSocket in Java Swing Application -


i created small java swing application , want use websocket transferring of data server client. can give me step step instructions on how it? i'm using jboss application server.

one approach use jetty websocket client api, hopping implemented server side web socket

tutorial

maven dependency org.eclipse.jetty.websocket websocket-client ${project.version}

  package examples;   import java.net.uri;  import java.util.concurrent.timeunit;  import org.eclipse.jetty.websocket.client.clientupgraderequest;  import org.eclipse.jetty.websocket.client.websocketclient;   public class simpleechoclient {  public static void main(string[] args) {     string desturi = "ws://echo.websocket.org";     if (args.length > 0) {         desturi = args[0];     }     websocketclient client = new websocketclient();     simpleechosocket socket = new simpleechosocket();     try {         client.start();         uri echouri = new uri(desturi);         clientupgraderequest request = new clientupgraderequest();         client.connect(socket, echouri, request);         system.out.printf("connecting : %s%n", echouri);         socket.awaitclose(5, timeunit.seconds);     } catch (throwable t) {         t.printstacktrace();     } {         try {             client.stop();         } catch (exception e) {             e.printstacktrace();         }     } } } 

Comments