Browse Source

调整log工具

lvjincheng 3 years ago
parent
commit
b453130de2
2 changed files with 9 additions and 2 deletions
  1. 1 1
      Assets/BowArrow/DebugShoot/BluetoothClient.cs
  2. 8 1
      Assets/JC/JCEngine.cs

+ 1 - 1
Assets/BowArrow/DebugShoot/BluetoothClient.cs

@@ -22,7 +22,7 @@ public class BluetoothClient : MonoBehaviour
     void Start()
     void Start()
     {
     {
         ins = this;
         ins = this;
-        JCEngine.boot("ws://" + serverIP + ":9888/BLE", client);
+        JCEngine.bootNew("ws://" + serverIP + ":9888/BLE", client);
     }
     }
 
 
     public static void UploadData(byte sign, byte[] bytes) 
     public static void UploadData(byte sign, byte[] bytes) 

+ 8 - 1
Assets/JC/JCEngine.cs

@@ -17,6 +17,9 @@ namespace JCEngineCore {
         public static void reboot(JCEntity entity) {
         public static void reboot(JCEntity entity) {
             new JCEngineCore.WebSocketServer(url, entity);
             new JCEngineCore.WebSocketServer(url, entity);
         }
         }
+        public static void bootNew(string url, JCEntity entity) {
+            new JCEngineCore.WebSocketServer(url, entity);
+        }
     }
     }
     public class JCEntity {
     public class JCEntity {
         public int id;
         public int id;
@@ -164,7 +167,11 @@ namespace JCEngineCore {
         IEnumerator doHeartBeat() {
         IEnumerator doHeartBeat() {
             while (true) {
             while (true) {
                 try {
                 try {
-                    call("doHeartBeat");
+                    if (webSocket.IsOpen) {
+                        call("doHeartBeat");
+                    } else {
+                        break;
+                    }
                 } catch (System.Exception) {}
                 } catch (System.Exception) {}
                 yield return new WaitForSecondsRealtime(5f);
                 yield return new WaitForSecondsRealtime(5f);
             }
             }