184a1ab453aafe41149fab0e663b49d85cf0896cbPaul Hawkepackage fi.iki.elonen.samples.echo; 284a1ab453aafe41149fab0e663b49d85cf0896cbPaul Hawke 384a1ab453aafe41149fab0e663b49d85cf0896cbPaul Hawkeimport fi.iki.elonen.NanoWebSocketServer; 4c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke 5c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawkeimport java.io.IOException; 6c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke 7c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawkepublic class EchoSocketSample { 8c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke public static void main(String[] args) throws IOException { 9c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke final boolean debugMode = args.length >= 2 && args[1].toLowerCase().equals("-d"); 10c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke NanoWebSocketServer ws = new DebugWebSocketServer(Integer.parseInt(args[0]), debugMode); 11c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke ws.start(); 12c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke System.out.println("Server started, hit Enter to stop.\n"); 13c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke try { 14c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke System.in.read(); 15c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke } catch (IOException ignored) { 16c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke } 17c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke ws.stop(); 18c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke System.out.println("Server stopped.\n"); 19c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke } 20c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke 21c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke} 22c6c080a6f4377fb18fc869111714e9514c36331aPaul Hawke 23