Connection retry in chat.
This commit is contained in:
@@ -293,6 +293,7 @@ body {
|
|||||||
|
|
||||||
.systemMessage {
|
.systemMessage {
|
||||||
color: #5f5f5f;
|
color: #5f5f5f;
|
||||||
|
font-size: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gameMessage {
|
.gameMessage {
|
||||||
|
|||||||
@@ -10,9 +10,12 @@ var ChatBoxUI = Class.extend({
|
|||||||
chatUpdateInterval: 1000,
|
chatUpdateInterval: 1000,
|
||||||
unsentMessages: null,
|
unsentMessages: null,
|
||||||
processingMessages: null,
|
processingMessages: null,
|
||||||
|
retryCount: null,
|
||||||
|
maxRetryCount: 5,
|
||||||
|
|
||||||
init: function(name, div, url, showList) {
|
init: function(name, div, url, showList) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
this.retryCount = 0;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.div = div;
|
this.div = div;
|
||||||
this.unsentMessages = new Array();
|
this.unsentMessages = new Array();
|
||||||
@@ -29,17 +32,27 @@ var ChatBoxUI = Class.extend({
|
|||||||
that.appendMessage("Server is being restarted, please wait for the restart to finish and try again later.", "warningMessage");
|
that.appendMessage("Server is being restarted, please wait for the restart to finish and try again later.", "warningMessage");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
that.appendMessage("Chat had a problem communicating with the server (error " + xhr.statis + "). Retrying...", "systemMessage");
|
that.retryCount++;
|
||||||
setTimeout(function() {
|
if (that.retryCount <= that.maxRetryCount) {
|
||||||
that.updateChatMessages();
|
that.appendMessage("Chat had a problem communicating with the server (error " + xhr.status + "). Retrying (" + that.retryCount + " of " + that.maxRetryCount + ")...", "systemMessage");
|
||||||
}, that.chatUpdateInterval);
|
setTimeout(function() {
|
||||||
|
that.updateChatMessages();
|
||||||
|
}, that.chatUpdateInterval);
|
||||||
|
} else {
|
||||||
|
that.appendMessage("Chat has given up on connection retry (tried " + that.maxRetryCount + "), make sure your connection with the Internet is working.", "warningMessage");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
that.appendMessage("Chat had an unknown problem communicating with the server. Retrying...", "systemMessage");
|
that.retryCount++;
|
||||||
setTimeout(function() {
|
if (that.retryCount <= that.maxRetryCount) {
|
||||||
that.updateChatMessages();
|
that.appendMessage("Chat had an unkown problem communicating with the server. Retrying (" + that.retryCount + " of " + that.maxRetryCount + ")...", "systemMessage");
|
||||||
}, that.chatUpdateInterval);
|
setTimeout(function() {
|
||||||
|
that.updateChatMessages();
|
||||||
|
}, that.chatUpdateInterval);
|
||||||
|
} else {
|
||||||
|
that.appendMessage("Chat has given up on connection retry (tried " + that.maxRetryCount + "), make sure your connection with the Internet is working.", "warningMessage");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -116,6 +129,7 @@ var ChatBoxUI = Class.extend({
|
|||||||
processMessages: function(xml, processAgain) {
|
processMessages: function(xml, processAgain) {
|
||||||
var root = xml.documentElement;
|
var root = xml.documentElement;
|
||||||
if (root.tagName == 'chat') {
|
if (root.tagName == 'chat') {
|
||||||
|
this.retryCount = 0;
|
||||||
this.processingMessages = null;
|
this.processingMessages = null;
|
||||||
var messages = root.getElementsByTagName("message");
|
var messages = root.getElementsByTagName("message");
|
||||||
for (var i = 0; i < messages.length; i++) {
|
for (var i = 0; i < messages.length; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user