Просмотр исходного кода

Handle reconnection when the server is restarted

dev_h
Ophir LOJKINE 6 лет назад
Родитель
Сommit
e708bd79cb
1 измененных файлов: 5 добавлений и 1 удалений
  1. 5
    1
      client-data/js/board.js

+ 5
- 1
client-data/js/board.js Просмотреть файл

@@ -29,7 +29,8 @@ var Tools = {};
29 29
 Tools.board = document.getElementById("board");
30 30
 Tools.svg = document.getElementById("canvas");
31 31
 Tools.socket = io.connect('', {
32
-	"reconnection delay": 1, //Make the xhr connections as fast as possible
32
+	"reconnectionDelay": 100, //Make the xhr connections as fast as possible
33
+	"timeout": 1000 * 60 * 20 // Timeout after 20 minutes
33 34
 });
34 35
 Tools.curTool = null;
35 36
 Tools.boardName = (function () {
@@ -204,6 +205,9 @@ function handleMessage(message) {
204 205
 
205 206
 //Receive draw instructions from the server
206 207
 Tools.socket.on("broadcast", handleMessage);
208
+Tools.socket.on("reconnect", function onReconnection() {
209
+	Tools.socket.emit("getboard", Tools.boardName);
210
+});
207 211
 
208 212
 Tools.unreadMessagesCount = 0;
209 213
 Tools.newUnreadMessage = function () {

Загрузка…
Отмена
Сохранить