2 次代碼提交 27191c78b3 ... 3542087f2a

作者 SHA1 備註 提交日期
  Dim Dim 3542087f2a gitignore 6 年之前
  Dim Dim 7efc76ca02 Small changes sockets 6 年之前
共有 3 個文件被更改,包括 9 次插入0 次删除
  1. 1 0
      .gitignore
  2. 7 0
      src/Game/services/GameService.js
  3. 1 0
      src/Game/services/SocketService.js

+ 1 - 0
.gitignore

@@ -15,6 +15,7 @@
 .env.development.local
 .env.test.local
 .env.production.local
+.idea
 
 npm-debug.log*
 yarn-debug.log*

+ 7 - 0
src/Game/services/GameService.js

@@ -22,6 +22,7 @@ class GameService {
 
         if(this.onInit) this.onInit();
         SocketService.on('move', (data) => this.move(data));
+        SocketService.on('result', (data) => this.end(data));
     }
 
     move(data) {
@@ -41,6 +42,12 @@ class GameService {
         if(this.onUpdate) this.onUpdate(1);
     }
 
+    end(data) {
+
+
+
+        SocketService.close();
+    }
 
 }
 

+ 1 - 0
src/Game/services/SocketService.js

@@ -10,6 +10,7 @@ class SocketService {
         this.socket = openSocket('http://localhost:3555/' + channel);
         this.on = this.socket.on.bind(this.socket);
         this.emit = this.socket.emit.bind(this.socket);
+        this.close = this.socket.close.bind(this.socket);
     }