|
|
@@ -13,6 +13,8 @@ import okio.ByteString;
|
|
|
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.logging.Level;
|
|
|
+import java.util.logging.Logger;
|
|
|
|
|
|
/**
|
|
|
* @author reghao
|
|
|
@@ -38,6 +40,7 @@ public class WsClient implements MessageSender {
|
|
|
this.webSocketListener = new WebSocketListenerImpl(this, eventCenter, machineEvent);
|
|
|
this.retry = true;
|
|
|
this.retryCount = 0;
|
|
|
+ Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
|
|
|
}
|
|
|
|
|
|
public void setRetry(boolean retry) {
|
|
|
@@ -73,6 +76,12 @@ public class WsClient implements MessageSender {
|
|
|
.readTimeout(60, TimeUnit.SECONDS)
|
|
|
.writeTimeout(60, TimeUnit.SECONDS)
|
|
|
.build();
|
|
|
+
|
|
|
+ if (this.webSocket != null) {
|
|
|
+ this.webSocket.cancel();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
this.webSocket = okHttpClient.newWebSocket(request, webSocketListener);
|
|
|
}
|
|
|
|