Browse Source

Handle reconnection when the server is restarted

dev_h
Ophir LOJKINE 7 years ago
parent
commit
e708bd79cb
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      client-data/js/board.js

+ 5
- 1
client-data/js/board.js View File

29
 Tools.board = document.getElementById("board");
29
 Tools.board = document.getElementById("board");
30
 Tools.svg = document.getElementById("canvas");
30
 Tools.svg = document.getElementById("canvas");
31
 Tools.socket = io.connect('', {
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
 Tools.curTool = null;
35
 Tools.curTool = null;
35
 Tools.boardName = (function () {
36
 Tools.boardName = (function () {
204
 
205
 
205
 //Receive draw instructions from the server
206
 //Receive draw instructions from the server
206
 Tools.socket.on("broadcast", handleMessage);
207
 Tools.socket.on("broadcast", handleMessage);
208
+Tools.socket.on("reconnect", function onReconnection() {
209
+	Tools.socket.emit("getboard", Tools.boardName);
210
+});
207
 
211
 
208
 Tools.unreadMessagesCount = 0;
212
 Tools.unreadMessagesCount = 0;
209
 Tools.newUnreadMessage = function () {
213
 Tools.newUnreadMessage = function () {

Loading…
Cancel
Save