Skip to content
Browse files

Moved away message code into IRC class, flood protection, and reorder…

…ing of connection template.
  • Loading branch information...
1 parent f54de2e commit 1a389c31def78315ba30214c7b6df41a6fa48734 @ericbarch ericbarch committed Jul 7, 2012
Showing with 19 additions and 16 deletions.
  1. +12 −1 lib/irclink.js
  2. +1 −1 lib/restore.js
  3. +0 −8 lib/socket.js
  4. +6 −6 views/templates.jade
View
13 lib/irclink.js
@@ -37,7 +37,7 @@ var IRCLink = function(hostname, port, ssl, selfSigned, nick, realName, password
secure: ssl,
selfSigned: selfSigned,
certExpired: false,
- floodProtection: false,
+ floodProtection: true,
floodProtectionDelay: 1000,
stripColors: true
});
@@ -139,12 +139,23 @@ IRCLink.prototype = {
disconnect: function() {
this.client.disconnect();
},
+ setAway: function() {
+ this.client.send('AWAY', this.away);
+ },
addSocket: function(socket) {
+ // set ourselves as not being away
+ if (this.sockets.length == 0)
+ this.client.send('AWAY', '');
+
this.sockets.push(socket);
},
removeSocket: function(socket) {
var index = this.sockets.indexOf(socket);
if (index != -1) this.sockets.splice(index, 1);
+
+ // set ourselves as away
+ if (this.sockets.length == 0)
+ this.client.send('AWAY', this.away);
},
logMessage: function(target, msg) {
if (this.username) {
View
2 lib/restore.js
@@ -15,7 +15,7 @@ module.exports = function (connections) {
connection.associateUser(doc.user);
connections[doc.user] = connection;
// set ourselves as away
- connection.client.send('AWAY', doc.away);
+ connection.setAway();
});
});
}
View
8 lib/socket.js
@@ -83,10 +83,6 @@ module.exports = function(socket, connections) {
socket.emit('restore_connection', {nick: connection.client.nick,
server: connection.client.opt.server, channels: connection.client.chans});
connection.clearUnreads();
-
- // set ourselves as not being away
- if (connection.sockets.length == 0)
- connection.client.send('AWAY', '');
}
// register this socket with our user's IRC connection
@@ -156,10 +152,6 @@ module.exports = function(socket, connections) {
// keep the session alive, remove this socket, and clear unreads
connection.removeSocket(socket);
connection.clearUnreads();
-
- // set ourselves as away
- if (connection.sockets.length == 0)
- connection.client.send('AWAY', connection.away);
}
});
View
12 views/templates.jade
@@ -46,10 +46,6 @@ script(id="overview_connection", type="text/html")
label(for="connect-secure") SSL
.controls
input#connect-secure(type="checkbox")
- .control-group
- label(for="connect-rejoin") Bouncer Mode
- .controls
- input#connect-rejoin(type="checkbox")
.control-group#ssl-self-signed
label(for="connect-selfSigned") Self-signed SSL Cert
.controls
@@ -59,6 +55,10 @@ script(id="overview_connection", type="text/html")
.controls
input#connect-nick(type="text")
.control-group
+ label(for="connect-password") Password (optional)
+ .controls
+ input#connect-password(type="password")
+ .control-group
label(for="connect-realName") Real Name
.controls
input#connect-realName(type="text")
@@ -67,9 +67,9 @@ script(id="overview_connection", type="text/html")
.controls
input#connect-away(type="text", placeholder="AFK")
.control-group
- label(for="connect-password") Password
+ label(for="connect-rejoin") Bouncer Mode
.controls
- input#connect-password(type="password")
+ input#connect-rejoin(type="checkbox")
a(id="connect-button", class="btn btn-primary", type="button") Connect
script(id="overview_settings", type="text/html")

0 comments on commit 1a389c3

Please sign in to comment.
Something went wrong with that request. Please try again.