io.vertx.core.http.impl.ws.WebSocketFrameImpl Java Examples
The following examples show how to use
io.vertx.core.http.impl.ws.WebSocketFrameImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndWrite() throws InterruptedException { getClient().websocket(8080, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #2
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll_1() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll_1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #3
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/wsEndpintThree", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #4
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReply() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/wsEndpintTwo", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReply:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #5
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndAsyncWrite() throws InterruptedException { getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/asyncReply", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndAsyncWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndAsyncWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #6
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndWrite() throws InterruptedException { getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #7
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll_1() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll_1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #8
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, HOST, SERVICE_REST_GET + "/wsEndpintThree", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #9
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReply() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, HOST, SERVICE_REST_GET + "/wsEndpintTwo", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReply:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #10
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndAsyncWrite() throws InterruptedException { getClient().websocket(8080, HOST, SERVICE_REST_GET + "/asyncReply", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndAsyncWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndAsyncWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #11
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndWrite() throws InterruptedException { getClient().websocket(8080, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #12
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll_1() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll_1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #13
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReplyToAll() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/wsEndpintThree", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAll:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #14
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleMutilpeReply() throws InterruptedException { final AtomicInteger counter = new AtomicInteger(0); getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/wsEndpintTwo", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReply:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); if (counter.incrementAndGet() == MAX_RESPONSE_ELEMENTS) { ws.close(); testComplete(); } }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #15
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 6 votes |
@Test public void simpleConnectAndAsyncWrite() throws InterruptedException { getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/asyncReply", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectAndAsyncWrite:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); long endTime = System.currentTimeMillis(); System.out.println("Total execution time simpleConnectAndAsyncWrite: " + (endTime - startTime) + "ms"); testComplete(); }); ws.writeFrame(new WebSocketFrameImpl("xhello")); }); await(); }
Example #16
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 5 votes |
@Test public void simpleConnectOnTwoThreads() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(2); CountDownLatch latchMain = new CountDownLatch(2); Runnable r = () -> { getClient().websocket(8080, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTwoThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTwoThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("yhello")); }); }; s.submit(r); s.submit(r); latchMain.await(); }
Example #17
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 5 votes |
@Test public void simpleConnectOnTwoThreads() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(2); CountDownLatch latchMain = new CountDownLatch(2); Runnable r = () -> { getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTwoThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTwoThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("yhello")); }); }; s.submit(r); s.submit(r); latchMain.await(); }
Example #18
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 5 votes |
@Test public void simpleConnectOnTwoThreads() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(2); CountDownLatch latchMain = new CountDownLatch(2); Runnable r = () -> { getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTwoThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTwoThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("yhello")); }); }; s.submit(r); s.submit(r); latchMain.await(); }
Example #19
Source File: ConfigCenterClient.java From servicecomb-java-chassis with Apache License 2.0 | 5 votes |
private void sendHeartbeat(WebSocket ws) { try { ws.writeFrame(new WebSocketFrameImpl(FrameType.PING)); EventManager.post(new ConnSuccEvent()); } catch (IllegalStateException e) { EventManager.post(new ConnFailEvent("heartbeat fail, " + e.getMessage())); LOGGER.error("heartbeat fail", e); } }
Example #20
Source File: SockJSHandlerTest.java From vertx-web with Apache License 2.0 | 5 votes |
@Test public void testCombineTextFrameSockJs() throws InterruptedException { String serverPath = "/text-combine-sockjs"; setupSockJsServer(serverPath, this::echoRequest); List<Buffer> receivedMessages = new ArrayList<>(); WebSocket openedWebSocket = setupSockJsClient(serverPath, receivedMessages); Buffer largeMessage = Buffer.buffer("[\"" + TestUtils.randomAlphaString(30) + "\"]"); WebSocketFrame frame1 = new WebSocketFrameImpl(FrameType.TEXT, largeMessage.slice(0, 10).getByteBuf(), false); WebSocketFrame frame2 = WebSocketFrame.continuationFrame(largeMessage.slice(10, 20), false); WebSocketFrame frame3 = WebSocketFrame.continuationFrame(largeMessage.slice(20, largeMessage.length()), true); log.debug("Client sending " + frame1.textData()); openedWebSocket.writeFrame(frame1); log.debug("Client sending " + frame2.textData()); openedWebSocket.writeFrame(frame2); log.debug("Client sending " + frame3.textData()); openedWebSocket.writeFrame(frame3); await(5, TimeUnit.SECONDS); assertEquals("Client should have received 2 messages: the reply and the close.", 2, receivedMessages.size()); Buffer expectedReply = Buffer.buffer("a" + largeMessage.toString()); assertEquals("Client reply should have matched request", expectedReply, receivedMessages.get(0)); assertEquals("Final message should have been a close", SOCKJS_CLOSE_REPLY, receivedMessages.get(1)); }
Example #21
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleConnectOnTenThreads() throws InterruptedException { int counter =100; ExecutorService s = Executors.newFixedThreadPool(counter); CountDownLatch latchMain = new CountDownLatch(counter); for(int i =0; i<=counter; i++) { Runnable r = () -> { getClient().websocket(8080, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTenThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTenThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("zhello")); }); }; s.submit(r); } latchMain.await(); }
Example #22
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleMutilpeReplyToAllThreaded() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(10); final CountDownLatch latch = new CountDownLatch(2); getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAllThreaded:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); }); getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client datasimpleMutilpeReplyToAllThreaded 5.1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); ws.writeFrame(new WebSocketFrameImpl("xhello simpleMutilpeReplyToAllThreaded")); }); latch.await(); }
Example #23
Source File: WSServiceTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleMutilpeReplyToAllThreaded() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(10); final CountDownLatch latch = new CountDownLatch(2); getClient().websocket(8080, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAllThreaded:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); }); getClient().websocket(8080, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client datasimpleMutilpeReplyToAllThreaded 5.1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); ws.writeFrame(new WebSocketFrameImpl("xhello simpleMutilpeReplyToAllThreaded")); }); latch.await(); }
Example #24
Source File: WSClusteredServiceTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleConnectOnTenThreads() throws InterruptedException { int counter =10; ExecutorService s = Executors.newFixedThreadPool(counter); CountDownLatch latchMain = new CountDownLatch(counter); for(int i =0; i<=counter; i++) { Runnable r = () -> { getClient().websocket(8080, "localhost", SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTenThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTenThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("zhello")); }); }; s.submit(r); } latchMain.await(); }
Example #25
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleConnectOnTenThreads() throws InterruptedException { int counter =100; ExecutorService s = Executors.newFixedThreadPool(counter); CountDownLatch latchMain = new CountDownLatch(counter); for(int i =0; i<=counter; i++) { Runnable r = () -> { getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/hello", ws -> { long startTime = System.currentTimeMillis(); ws.handler((data) -> { System.out.println("client data simpleConnectOnTenThreads:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); ws.close(); latchMain.countDown(); long endTime = System.currentTimeMillis(); System.out.println("round trip time simpleConnectOnTenThreads: " + (endTime - startTime) + "ms"); }); ws.writeFrame(new WebSocketFrameImpl("zhello")); }); }; s.submit(r); } latchMain.await(); }
Example #26
Source File: WSServiceSelfhostedTest.java From vert.x-microservice with Apache License 2.0 | 3 votes |
@Test public void simpleMutilpeReplyToAllThreaded() throws InterruptedException { ExecutorService s = Executors.newFixedThreadPool(10); final CountDownLatch latch = new CountDownLatch(2); getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client data simpleMutilpeReplyToAllThreaded:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); }); getClient().websocket(PORT, HOST, SERVICE_REST_GET + "/wsEndpintFour", ws -> { ws.handler((data) -> { System.out.println("client datasimpleMutilpeReplyToAllThreaded 5.1:" + new String(data.getBytes())); assertNotNull(data.getString(0, data.length())); latch.countDown(); ws.close(); }); ws.writeFrame(new WebSocketFrameImpl("xhello simpleMutilpeReplyToAllThreaded")); }); latch.await(); }