public void end() { this.localWebSocketServer.stop(); this.localWebSocketServer = null; }
/** * Stop the server. * * @param server to be stopped. */ protected void stopServer(Server server) { if (server != null) { server.stop(); } }
/** * Stop the server. * * @param server to be stopped. */ protected void stopServer(Server server) { if (server != null) { server.stop(); } }
@Override public void close() { if (closed) return; synchronized (lock) { if (server != null) { closed = true; server.stop(); openSessions.closeAll(); openSessions = null; running = false; server = null; globalListener = null; } } }
public static void main(String[] args) { if (args.length < 4) { System.out.println( "Please provide: (<hostname>, <port>, <websockets root path>, <;-sep fully qualfied classnames of" + " your bean>) in the command line"); System.out.println("e.g. localhost 8021 /websockets/myapp myapp.Bean1;myapp.Bean2"); System.exit(1); } Set<Class<?>> beanClasses = getClassesFromString(args[3]); int port = Integer.parseInt(args[1]); String hostname = args[0]; String wsroot = args[2]; Server server = new Server(hostname, port, wsroot, null, beanClasses); try { server.start(); System.out.println("Press any key to stop the WebSocket server..."); //noinspection ResultOfMethodCallIgnored System.in.read(); } catch (IOException ioe) { System.err.println("IOException during server run"); ioe.printStackTrace(); } catch (DeploymentException de) { de.printStackTrace(); } finally { server.stop(); } }
public static void main(String[] args) { if (args.length < 4) { System.out.println( "Please provide: (<hostname>, <port>, <websockets root path>, <;-sep fully qualfied classnames of" + " your bean>) in the command line"); System.out.println("e.g. localhost 8021 /websockets/myapp myapp.Bean1;myapp.Bean2"); System.exit(1); } Set<Class<?>> beanClasses = getClassesFromString(args[3]); int port = Integer.parseInt(args[1]); String hostname = args[0]; String wsroot = args[2]; Server server = new Server(hostname, port, wsroot, null, beanClasses); try { server.start(); System.out.println("Press any key to stop the WebSocket server..."); //noinspection ResultOfMethodCallIgnored System.in.read(); } catch (IOException ioe) { System.err.println("IOException during server run"); ioe.printStackTrace(); } catch (DeploymentException de) { de.printStackTrace(); } finally { server.stop(); } }
/** * Starts a WebSocket server that has two endpoints, one that generates * String payloads and another that generates binary payloads. */ @Test public void startWebSocketServer() { Server server = new Server("localhost", 6543, "/sitewhere", null, WebSocketConfiguration.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 (Exception e) { e.printStackTrace(); } finally { server.stop(); } } }