Skip to content

Instantly share code, notes, and snippets.

@wnds
Created April 20, 2017 17:39
Show Gist options
  • Save wnds/5498ff21c42bfb1368c40a198076f9fd to your computer and use it in GitHub Desktop.
Save wnds/5498ff21c42bfb1368c40a198076f9fd to your computer and use it in GitHub Desktop.
package org.vivek.j2ee.websockets.server;
import org.glassfish.tyrus.server.Server;
import javax.websocket.DeploymentException;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WebSocketServerWrapper {
public static void main(String args[]) {
runServer();
}
private static void runServer() {
Server server = new Server("localhost", 8025, "/websocket", EchoWebSocketEndPoint.class);
try {
server.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Please press a key to stop the server.");
reader.readLine();
} catch (DeploymentException | IOException e) {
e.printStackTrace();
} finally {
server.stop();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment