lvjincheng 3 лет назад
Родитель
Сommit
b453130de2
2 измененных файлов с 9 добавлено и 2 удалено
  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()
     {
         ins = this;
-        JCEngine.boot("ws://" + serverIP + ":9888/BLE", client);
+        JCEngine.bootNew("ws://" + serverIP + ":9888/BLE", client);
     }
 
     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) {
             new JCEngineCore.WebSocketServer(url, entity);
         }
+        public static void bootNew(string url, JCEntity entity) {
+            new JCEngineCore.WebSocketServer(url, entity);
+        }
     }
     public class JCEntity {
         public int id;
@@ -164,7 +167,11 @@ namespace JCEngineCore {
         IEnumerator doHeartBeat() {
             while (true) {
                 try {
-                    call("doHeartBeat");
+                    if (webSocket.IsOpen) {
+                        call("doHeartBeat");
+                    } else {
+                        break;
+                    }
                 } catch (System.Exception) {}
                 yield return new WaitForSecondsRealtime(5f);
             }