mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix for irc client - to make connection "lazy", so it doesn't start untill needed.
This commit is contained in:
parent
56476312c1
commit
f1bcf130aa
@ -24,28 +24,29 @@ function IRCServerNode(n) {
|
|||||||
this.server = n.server;
|
this.server = n.server;
|
||||||
this.channel = n.channel;
|
this.channel = n.channel;
|
||||||
this.nickname = n.nickname;
|
this.nickname = n.nickname;
|
||||||
this.ircclient = new irc.Client(this.server, this.nickname, {
|
this.ircclient = null;
|
||||||
channels: [this.channel]
|
this.on("close", function() {
|
||||||
|
if (this.ircclient != null) {
|
||||||
|
this.ircclient.disconnect();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.ircclient.addListener('error', function(message) {
|
|
||||||
util.log('[irc] '+ JSON.stringify(message));
|
|
||||||
});
|
|
||||||
this._close = function() {
|
|
||||||
this.ircclient.disconnect();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RED.nodes.registerType("irc-server",IRCServerNode);
|
RED.nodes.registerType("irc-server",IRCServerNode);
|
||||||
IRCServerNode.prototype.close = function() {
|
|
||||||
this._close();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// The Input Node
|
// The Input Node
|
||||||
function IrcInNode(n) {
|
function IrcInNode(n) {
|
||||||
RED.nodes.createNode(this,n);
|
RED.nodes.createNode(this,n);
|
||||||
this.ircserver = n.ircserver;
|
this.ircserver = n.ircserver;
|
||||||
this.serverConfig = RED.nodes.getNode(this.ircserver);
|
this.serverConfig = RED.nodes.getNode(this.ircserver);
|
||||||
|
if (this.serverConfig.ircclient == null) {
|
||||||
|
this.serverConfig.ircclient = new irc.Client(this.serverConfig.server, this.serverConfig.nickname, {
|
||||||
|
channels: [this.serverConfig.channel]
|
||||||
|
});
|
||||||
|
this.serverConfig.ircclient.addListener('error', function(message) {
|
||||||
|
util.log('[irc] '+ JSON.stringify(message));
|
||||||
|
});
|
||||||
|
}
|
||||||
this.ircclient = this.serverConfig.ircclient;
|
this.ircclient = this.serverConfig.ircclient;
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
@ -64,8 +65,16 @@ function IrcOutNode(n) {
|
|||||||
this.sendAll = n.sendObject;
|
this.sendAll = n.sendObject;
|
||||||
this.ircserver = n.ircserver;
|
this.ircserver = n.ircserver;
|
||||||
this.serverConfig = RED.nodes.getNode(this.ircserver);
|
this.serverConfig = RED.nodes.getNode(this.ircserver);
|
||||||
this.ircclient = this.serverConfig.ircclient;
|
|
||||||
this.channel = this.serverConfig.channel;
|
this.channel = this.serverConfig.channel;
|
||||||
|
if (this.serverConfig.ircclient == null) {
|
||||||
|
this.serverConfig.ircclient = new irc.Client(this.serverConfig.server, this.serverConfig.nickname, {
|
||||||
|
channels: [this.serverConfig.channel]
|
||||||
|
});
|
||||||
|
this.serverConfig.ircclient.addListener('error', function(message) {
|
||||||
|
util.log('[irc] '+ JSON.stringify(message));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.ircclient = this.serverConfig.ircclient;
|
||||||
var node = this;
|
var node = this;
|
||||||
|
|
||||||
this.on("input", function(msg) {
|
this.on("input", function(msg) {
|
||||||
|
Loading…
Reference in New Issue
Block a user