3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 14:29:29 +01:00

multiple udp clients

This commit is contained in:
reality 2016-05-07 16:04:10 +00:00
parent 2b043d018b
commit aeea5a7e18
2 changed files with 9 additions and 4 deletions

View File

@ -1,6 +1,8 @@
{
"services": [{
"port":14628,
"address": "127.0.0.1",
"server": "freenode",
"channel": "#oaosidl"
}]
}

View File

@ -6,17 +6,20 @@
var dgram = require('dgram');
var udp = function(dbot) {
_.each(dbot.config.modules.udp.servers, function(data) {
var server = dgram.createSocket("udp4");
server.on("message", function(msg, msginfo) {
var message = msg.toString();
console.log(message);
if (msginfo.address == this.config.address) {
dbot.say(this.config.server, this.config.channel, message);
if (msginfo.address == data.address) {
dbot.say(data.server, data.channel, message);
}
}.bind(this));
this.onLoad = function() {
server.bind(this.config.port);
_.each(dbot.config.modules.udp.servers, function(data) {
server.bind(data.port);
});
}.bind(this);
}.bind(this));
};
exports.fetch = function(dbot) {