mirror of
https://github.com/reality/dbot.git
synced 2024-12-28 05:32:50 +01:00
multiple udp clients
This commit is contained in:
parent
2b043d018b
commit
aeea5a7e18
@ -1,6 +1,8 @@
|
||||
{
|
||||
"services": [{
|
||||
"port":14628,
|
||||
"address": "127.0.0.1",
|
||||
"server": "freenode",
|
||||
"channel": "#oaosidl"
|
||||
}]
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user