63 verse.set_logger(opts.verbose and print or function () end); |
63 verse.set_logger(opts.verbose and print or function () end); |
64 local conn = verse.new(verse.logger()); |
64 local conn = verse.new(verse.logger()); |
65 conn.log.debug = opts.verbose; |
65 conn.log.debug = opts.verbose; |
66 conn:hook("authentication-failure", function (err) |
66 conn:hook("authentication-failure", function (err) |
67 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
67 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
|
68 conn:close(); |
68 end); |
69 end); |
69 conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end); |
70 conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end); |
70 conn:hook("binding-failure", function (err) |
71 conn:hook("binding-failure", function (err) |
71 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
72 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
|
73 conn:close(); |
72 end); |
74 end); |
73 conn:hook("disconnected", function (info) |
75 conn:hook("disconnected", function (info) |
74 if info.reason then |
76 if info.reason then |
75 conn:warn("Disconnecting: %s", tostring(info.reason)); |
77 conn:warn("Disconnecting: %s", tostring(info.reason)); |
76 end |
78 end |