Software /
code /
prosody
Comparison
net/resolvers/manual.lua @ 8531:601681acea73
net.connect: New API for outgoing connections, based on 'service resolvers'
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 23 Feb 2018 15:53:45 +0000 |
child | 9691:e11e076f0eb8 |
comparison
equal
deleted
inserted
replaced
8530:075df839c110 | 8531:601681acea73 |
---|---|
1 local methods = {}; | |
2 local resolver_mt = { __index = methods }; | |
3 | |
4 -- Find the next target to connect to, and | |
5 -- pass it to cb() | |
6 function methods:next(cb) | |
7 if #self.targets == 0 then | |
8 cb(nil); | |
9 return; | |
10 end | |
11 local next_target = table.remove(self.targets, 1); | |
12 cb(unpack(next_target, 1, 4)); | |
13 end | |
14 | |
15 local function new(targets, conn_type, extra) | |
16 return setmetatable({ | |
17 conn_type = conn_type; | |
18 extra = extra; | |
19 targets = targets or {}; | |
20 }, resolver_mt); | |
21 end | |
22 | |
23 return { | |
24 new = new; | |
25 }; |