public WebSocketServer(int port) { log.info("Starting Changes Plugin"); server = new Server("localhost", port, "/ws", null, WebSocketEndpoint.class); }
public void run() { this.localWebSocketServer = new Server(ws_hostname, ws_port, "/", userProperties, RuntimeWebSocketServerService.class); ClassLoader classLoader = Thread.currentThread() .getContextClassLoader(); ClassLoader currentClassloader = this.getClass().getClassLoader(); if (classLoader != null) { this.droolsPlatformKnowledgeBase.setProjectClassLoader(classLoader); Thread.currentThread().setContextClassLoader(currentClassloader); } try { localWebSocketServer.start(); } catch (DeploymentException e) { LOG.error("WebSocketServer.run", e); } finally { if (classLoader != null) { Thread.currentThread().setContextClassLoader(classLoader); } } }
/** * Start embedded server unless "tyrus.test.host" system property is specified. * * @param endpointClasses websocket endpoints and configs to be deployed. * @return new {@link Server} instance or {@code null} if "tyrus.test.host" system property is set. * @throws DeploymentException when the server cannot be started. */ protected Server startServer(Class<?>... endpointClasses) throws DeploymentException { final String host = System.getProperty("tyrus.test.host"); if (host == null) { final Server server = new Server(defaultHost, getPort(), contextPath, serverProperties, endpointClasses); server.start(); return server; } else { return null; } }
/** * Start embedded server unless "tyrus.test.host" system property is specified. * * @param endpointClasses websocket endpoints and configs to be deployed. * @return new {@link Server} instance or {@code null} if "tyrus.test.host" system property is set. * @throws DeploymentException when the server cannot be started. */ protected Server startServer(Class<?>... endpointClasses) throws DeploymentException { final String host = System.getProperty("tyrus.test.host"); if (host == null) { final Server server = new Server(defaultHost, getPort(), contextPath, serverProperties, endpointClasses); server.start(); return server; } else { return 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(); } }
server = new Server(hostName, port, "", new HashMap<String, Object>(), WebsocketServerEndpoint.class); server.start(); } catch (DeploymentException e) {
/** * 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(); } } }