From 0da9ac1a88d3a281872740b3082a0a026f320d1f Mon Sep 17 00:00:00 2001 From: liqiangqiang Date: Thu, 3 May 2018 15:23:29 +0800 Subject: [PATCH] =?UTF-8?q?=20WebFlux=20=E4=B8=AD=20WebSocket=20=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E9=80=9A=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/spring/springboot/handler/EchoHandler.java | 3 ++- .../src/main/resources/websocket-client.html | 10 ++++++---- .../src/test/java/WSClient.java | 2 ++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/springboot-webflux-8-websocket/src/main/java/org/spring/springboot/handler/EchoHandler.java b/springboot-webflux-8-websocket/src/main/java/org/spring/springboot/handler/EchoHandler.java index 8e36e59..a045582 100644 --- a/springboot-webflux-8-websocket/src/main/java/org/spring/springboot/handler/EchoHandler.java +++ b/springboot-webflux-8-websocket/src/main/java/org/spring/springboot/handler/EchoHandler.java @@ -12,6 +12,7 @@ public class EchoHandler implements WebSocketHandler { public Mono handle(final WebSocketSession session) { return session.send( session.receive() - .map(msg -> session.textMessage("服务端返回:小明, -> " + msg.getPayloadAsText()))); + .map(msg -> session.textMessage( + "服务端返回:小明, " + msg.getPayloadAsText()))); } } diff --git a/springboot-webflux-8-websocket/src/main/resources/websocket-client.html b/springboot-webflux-8-websocket/src/main/resources/websocket-client.html index 2f26cc2..ecbabad 100644 --- a/springboot-webflux-8-websocket/src/main/resources/websocket-client.html +++ b/springboot-webflux-8-websocket/src/main/resources/websocket-client.html @@ -6,22 +6,24 @@ -
+
+ diff --git a/springboot-webflux-8-websocket/src/test/java/WSClient.java b/springboot-webflux-8-websocket/src/test/java/WSClient.java index 0180132..ff5856e 100644 --- a/springboot-webflux-8-websocket/src/test/java/WSClient.java +++ b/springboot-webflux-8-websocket/src/test/java/WSClient.java @@ -7,6 +7,8 @@ import java.net.URI; import java.time.Duration; public class WSClient { + + public static void main(final String[] args) { final WebSocketClient client = new ReactorNettyWebSocketClient(); client.execute(URI.create("ws://localhost:8080/echo"), session ->