|
@@ -3,8 +3,10 @@ package com.xc.utils.websocket;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.xc.controller.websocket.WebSocketController;
|
|
|
import com.xc.service.InitStockListService;
|
|
|
+import com.xc.utils.PropertiesUtil;
|
|
|
import com.xc.vo.stock.StockVO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.java_websocket.WebSocket;
|
|
|
import org.java_websocket.client.WebSocketClient;
|
|
|
import org.java_websocket.handshake.ServerHandshake;
|
|
|
|
|
@@ -46,7 +48,33 @@ public class WsClient extends WebSocketClient {
|
|
|
|
|
|
@Override
|
|
|
public void onClose(int arg0, String arg1, boolean arg2) {
|
|
|
- System.out.println("连接关闭");
|
|
|
+ if(arg0==1006||arg0==1001){
|
|
|
+ Thread thread=new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ try {
|
|
|
+ boolean b = false ;
|
|
|
+ while(!b){
|
|
|
+ try {
|
|
|
+ String url = PropertiesUtil.getProperty("ws.url");
|
|
|
+ WsClient myClient = new WsClient(new URI(url));
|
|
|
+ myClient.connect();
|
|
|
+ Thread.sleep(5000);
|
|
|
+ if(myClient.getReadyState().equals(WebSocket.READYSTATE.OPEN)){
|
|
|
+ b = true;
|
|
|
+ System.out.println("订阅成功555");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ thread.start();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|