70 if ok then return; end |
70 if ok then return; end |
71 self:debug("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " ")); |
71 self:debug("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " ")); |
72 self:close("xml-not-well-formed"); |
72 self:close("xml-not-well-formed"); |
73 end |
73 end |
74 |
74 |
|
75 self:hook("connected", function () self:reopen(); end); |
75 self:hook("incoming-raw", function (data) return self.data(self.conn, data); end); |
76 self:hook("incoming-raw", function (data) return self.data(self.conn, data); end); |
76 |
77 |
77 self.curr_id = 0; |
78 self.curr_id = 0; |
78 |
79 |
79 self.tracked_iqs = {}; |
80 self.tracked_iqs = {}; |
134 end |
135 end |
135 |
136 |
136 local function start_connect() |
137 local function start_connect() |
137 -- Initialise connection |
138 -- Initialise connection |
138 self:connect(self.connect_host or self.host, self.connect_port or 5222); |
139 self:connect(self.connect_host or self.host, self.connect_port or 5222); |
139 self:reopen(); |
|
140 end |
140 end |
141 |
141 |
142 if not (self.connect_host or self.connect_port) then |
142 if not (self.connect_host or self.connect_port) then |
143 -- Look up SRV records |
143 -- Look up SRV records |
144 adns.lookup(function (answer) |
144 adns.lookup(function (answer) |