Skip to content

Commit

Permalink
Fixed issue nodester#45. By setting the option {'reconnect': false} o…
Browse files Browse the repository at this point in the history
…n initial socket connect, after a disconnect there is no automatic reconnect attempt from the socket.io client.

Removed the flag and the associated code.
  • Loading branch information
microp11 committed Apr 10, 2012
1 parent 45d88d5 commit 92c2cbf
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions public/js/app.js
Expand Up @@ -4,7 +4,6 @@ $(document).ready(function() {
nickname = null,
nicks = [], //could be an object if later we decide to add the nick attributes (+,... @)
webNicks = [], //web irc users
doNotReconnect = false, //prohibit reconnect to nodester server after a socket disconnect, no retries
motdPrevLineEmpty = false, //flag for determining if the prev motd line was only spaces and asterisks
//html elements
textInput = $('#text_input'),
Expand Down Expand Up @@ -116,15 +115,14 @@ $(document).ready(function() {

joinForm.on('submit', function(e) {
e.preventDefault();
doNotReconnect = false;
if (nickText.val() !== '') {
loginWrong.addClass('off');
loginMsg.removeClass('off');
chatBody.text("");
if (sock !== null && sock.socket.connected === false) {
sock.socket.reconnect();
} else {
sock = io.connect('http://' + window.location.host);
sock = io.connect('http://' + window.location.host, {'reconnect': false});
sock.on('message', handleMessage);
sock.on('disconnect', handleDisconnect);
sock.on('connect', handleConnect);
Expand Down Expand Up @@ -422,10 +420,6 @@ $(document).ready(function() {
};

var handleConnect = function () {
//cancel reconnect
if (doNotReconnect == true) {
return;
}
loginMsg.text("");
loginStatus.html("");
var nick = window.nick = getNickname(nickText.val());
Expand All @@ -440,16 +434,9 @@ $(document).ready(function() {

/*
* set a time delay for disconnect
*
* in case we exit the form we do not want the user to see it
* the socket has a reconnect timeout that does not help us with irc here
* so we make sure the socket won't reconnect: doNotReconnect = true
*/
var handleDisconnect = function () {
if (doNotReconnect == true) {
return;
};
doNotReconnect = true;
setTimeout( function () {
appendEvent("*", "disconnected", false);
nicks = [];
Expand Down

0 comments on commit 92c2cbf

Please sign in to comment.