public void testSlide() throws Exception { ExecutorService webThread = Executors.newSingleThreadExecutor(); final Pusher pusher = new Pusher(); Scripter rhiner = Scripter.create().start(); rhiner.start(); Craken r = Craken.inmemoryCreateWithTest(); r.start(); Radon radon = RadonConfiguration.newBuilder(9000) .add("/websocket/{id}", new BroadEchoWebSocket()) .add("/script/{id}", new ScriptWebSocket(rhiner, r)) .add( "/events/{id}", new EventSourceHandler() { public void onOpen(EventSourceConnection conn) throws Exception { pusher.addConnection(conn); } public void onClose(EventSourceConnection conn) throws Exception { pusher.removeConnection(conn); } }) .add("/*", new SimpleStaticFileHandler(new File("./resource/docs/"))) .createRadon(); radon.start().get(); pusher.pushPeriodicallyOn(webThread); new InfinityThread().startNJoin(); }
public static void main(String[] args) throws Exception { Radon webServer = newBuilder(9001) .add( new HttpToWebSocketHandler( new WebSocketHandler() { public void onOpen(WebSocketConnection connection) throws Exception {} public void onClose(WebSocketConnection connection) throws Exception {} public void onMessage(WebSocketConnection connection, String msg) throws Exception { connection.send(msg); } public void onMessage(WebSocketConnection connection, byte[] msg) { connection.send(msg); } public void onPong(WebSocketConnection connection, byte[] msg) {} public void onPing(WebSocketConnection connection, byte[] msg) { connection.pong(msg); } })) .connectionExceptionHandler(new PrintStackTraceExceptionHandler()) .startRadon(); System.out.println("Echo server running on: " + webServer.getConfig().publicUri()); }
protected void tearDown() throws Exception { radon.stop().get(); super.tearDown(); }