Dim Dim преди 6 години
родител
ревизия
7efc76ca02
променени са 2 файла, в които са добавени 8 реда и са изтрити 0 реда
  1. 7 0
      src/Game/services/GameService.js
  2. 1 0
      src/Game/services/SocketService.js

+ 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);
     }