diff --git a/pom.xml b/pom.xml
index 3c2cd6e..0536bb4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,17 +55,6 @@
jump3r
1.0.5
-
-
- com.google.protobuf
- protobuf-java
- 3.3.0
-
-
- org.springframework
- spring-web
- 5.3.25
-
diff --git a/src/main/java/cn/org/hentai/jtt1078/app/VideoServerApp.java b/src/main/java/cn/org/hentai/jtt1078/app/VideoServerApp.java
index 951d1a7..e302d38 100644
--- a/src/main/java/cn/org/hentai/jtt1078/app/VideoServerApp.java
+++ b/src/main/java/cn/org/hentai/jtt1078/app/VideoServerApp.java
@@ -47,17 +47,8 @@ public class VideoServerApp {
}
});
- try (WebsocketClient websocketClient = new WebsocketClient("ws://localhost:19800/ws", 15)) {
- // 连接
- websocketClient.connect();
- // 发送消息
- websocketClient.write("xxxxxxxxxxxxxxxxx");
- // 获取结果
- String result = websocketClient.receiveResult();
- logger.info("接收到结果[{}]", result);
- } catch (URISyntaxException | MyException e) {
- logger.error("发生异常,原因:{}", e.getMessage(), e);
- }
+ WebsocketClient wsClient = WebsocketClient.getWsInstance();
+ wsClient.connect();
videoServer.start();
httpServer.start();
diff --git a/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClient.java b/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClient.java
index b2c4e73..b2f10d6 100644
--- a/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClient.java
+++ b/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClient.java
@@ -30,7 +30,20 @@ public class WebsocketClient extends AbstractWebsocketClient {
private Channel channel;
- public WebsocketClient(String url, int connectionTimeout) throws URISyntaxException, MyException {
+ private static WebsocketClient wsInstance;
+
+ public static WebsocketClient getWsInstance() {
+ if (wsInstance == null) {
+ try {
+ wsInstance = new WebsocketClient("ws://localhost:19800/ws", 20);
+ } catch (URISyntaxException | MyException e) {
+ log.error("发生异常,原因:{}", e.getMessage(), e);
+ }
+ }
+ return wsInstance;
+ }
+
+ private WebsocketClient(String url, int connectionTimeout) throws URISyntaxException, MyException {
super(connectionTimeout, "ws");
this.uri = new URI(url);
this.port = getPort();
diff --git a/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClientHandler.java b/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClientHandler.java
index 696f7de..003ab80 100644
--- a/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClientHandler.java
+++ b/src/main/java/cn/org/hentai/jtt1078/app/websocket/WebsocketClientHandler.java
@@ -1,5 +1,6 @@
package cn.org.hentai.jtt1078.app.websocket;
+import cn.org.hentai.jtt1078.publisher.PublishManager;
import io.netty.channel.*;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
@@ -10,6 +11,10 @@ import io.netty.util.CharsetUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.xml.soap.Text;
+import java.util.Timer;
+import java.util.TimerTask;
+
public class WebsocketClientHandler extends SimpleChannelInboundHandler