Software / code / clix
Comparison
clix.lua @ 2:fd77e75c4891
clix: Make more use of Verse's new logging controls
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Wed, 06 Jan 2010 17:52:01 +0000 |
| parent | 0:ae83411a89c9 |
| child | 4:ead275885948 |
comparison
equal
deleted
inserted
replaced
| 1:58c694492459 | 2:fd77e75c4891 |
|---|---|
| 48 local account = accounts[opts.account or "default"]; | 48 local account = accounts[opts.account or "default"]; |
| 49 if not (account and account.jid) then | 49 if not (account and account.jid) then |
| 50 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n"); | 50 io.stderr:write("The specified account (", opts.account or "default", ") wasn't found in the config file\n"); |
| 51 return nil; | 51 return nil; |
| 52 end | 52 end |
| 53 | 53 verse.set_logger(function () end); |
| 54 local conn = verse.new(); | 54 local conn = verse.new(verse.logger()); |
| 55 conn.log.debug = opts.verbose; | |
| 55 conn:hook("authentication-failure", function (err) | 56 conn:hook("authentication-failure", function (err) |
| 56 io.stderr:write("Authentication failure (",err.condition or "unknown error", ")", err.text and (": "..err.text) or "", "\n"); | 57 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
| 57 end); | 58 end); |
| 58 conn:hook("binding-success", function () io.stderr:write("Connected: ", tostring(conn), "\n"); return on_connect(conn); end); | 59 conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end); |
| 59 conn:hook("binding-failure", function (err) | 60 conn:hook("binding-failure", function (err) |
| 60 io.stderr:write("Authentication failure (",err.condition or "unknown error", ")", err.text and (": "..err.text) or "", "\n"); | 61 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
| 61 end); | 62 end); |
| 62 conn:hook("disconnected", function (info) | 63 conn:hook("disconnected", function (info) |
| 63 if info.reason then | 64 if info.reason then |
| 64 io.stderr:write("Disconnecting: ", tostring(info.reason), "\n"); | 65 conn:warn("Disconnecting: %s", tostring(info.reason)); |
| 65 end | 66 end |
| 66 verse.quit(); | 67 verse.quit(); |
| 67 end); | 68 end); |
| 68 -- Optional config parameters | 69 -- Optional config parameters |
| 69 conn.connect_host = account.address; | 70 conn.connect_host = account.address; |