Skip to content
Browse files

Fixed ping/pong

  • Loading branch information...
1 parent 1d77419 commit 0707a66e12a6d639baa03aa613e2a07b3681a527 @sent1nel committed
Showing with 9 additions and 25 deletions.
  1. +8 −24 index.js
  2. +1 −1 tests/noob_client.js
View
32 index.js
@@ -16,32 +16,8 @@ function zIRCClient(stream, options) {
this.send_anyway = false;
this.commands_sent = 0;
- /*
- Client-generated event handling
- The driver accepts these events from the client
- - join
- - leave
- - kick
- - invite
- - topic
- - mode
- - say
- - msg
- - notice
- - away
- - back
- - whois
- - register
- - setNick
- - quit
- */
-
var self = this;
- this.on("PONG", function (hostname) {
- this.send_command("PONG %s", [ hostname ]);
- });
-
/*
Connection events
*/
@@ -129,6 +105,14 @@ zIRCClient.prototype.handle_command = function (message) {
return true;
}
+zIRCClient.prototype.pong = function (hostname) {
+ var command = "PONG";
+ if (typeof hostname === 'string') {
+ command = command + " " + hostname;
+ }
+ this.send_command(command);
+};
+
zIRCClient.prototype.join = function (channel, key) {
if (CHANNEL_PREFIXES.indexOf(channel.charAt(0)) == -1) {
channel = "#" + channel;
View
2 tests/noob_client.js
@@ -102,7 +102,7 @@ zirc_client.on("ready", function() {
});
zirc_client.on("PING", function() {
- zirc_client.emit("PONG", os.hostname());
+ zirc_client.pong(os.hostname());
});
zirc_client.on("error", function(err) {

0 comments on commit 0707a66

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