Skip to content

Commit

Permalink
Add error message for downed server
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 2, 2009
1 parent 165ba94 commit 1c5cf83
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
23 changes: 13 additions & 10 deletions client.js
Expand Up @@ -154,15 +154,21 @@ function handleKeyPress (e) {
if (e.keyCode != 13 /* Return */) return;

if (!util.isBlank(msg)) {
//addMessage(CONFIG.nick, msg);
send(msg);
}

commandHistory.unshift("");
clearEntry();
};

var longPollErrors = 0;
function longPoll (data) {

if (longPollErrors > 2) {
showConnect();
return;
}

if (data) {
if (data.messages) {
for (var i = 0; i < data.messages.length; i++) {
Expand Down Expand Up @@ -194,16 +200,13 @@ function longPoll (data) {
, dataType: "json"
, data: { since: CONFIG.last_message_time, id: CONFIG.id }
, error: function () {
console.log("long poll error! waiting 5 seconds");
setTimeout(longPoll, 5000);
addMessage("", "long poll error. trying again...", new Date(), "error");
longPollErrors += 1;
setTimeout(longPoll, 10*1000);
}
, success: function (data, textStatus) {
if (textStatus == "success") {
longPoll(data);
} else {
console.log("long poll error: " + textStatus);
setTimeout(longPoll, 5000);
}
, success: function (data) {
longPollErrors = 0;
longPoll(data);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion index.html
Expand Up @@ -16,7 +16,7 @@
</div>

<div class="buttons">
<input id="connectButton" class="button" type="submit" name="" value="Enter"/>
<input id="connectButton" class="button" type="submit" name="" value="Join"/>
</div>
</fieldset>
</form>
Expand Down
2 changes: 2 additions & 0 deletions style.css
Expand Up @@ -98,6 +98,8 @@ form.horizontal .field label {display: inline; float: left; width: 140px; margin

/* not very important info */
.notice td, .join td, .part td, .message .date { color: #555; }
.notice .nick { color: #cd5; }
.error td { color: #933; }

.message {
margin: 0.1em 0;
Expand Down

0 comments on commit 1c5cf83

Please sign in to comment.