Software /
code /
clix
Comparison
clix.lua @ 35:37540f89d4e2
clix.lua: Hook Verse's new 'ready' event instead of 'binding-success' and switch to 'bind-failure' for hooking resource bind failures
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 30 May 2010 02:56:40 +0100 |
parent | 34:d4f8fc71d936 |
child | 37:bb7a51aca282 |
comparison
equal
deleted
inserted
replaced
34:d4f8fc71d936 | 35:37540f89d4e2 |
---|---|
63 conn.log.debug = opts.verbose; | 63 conn.log.debug = opts.verbose; |
64 conn:hook("authentication-failure", function (err) | 64 conn:hook("authentication-failure", function (err) |
65 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); | 65 conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
66 conn:close(); | 66 conn:close(); |
67 end); | 67 end); |
68 conn:hook("binding-success", function () | 68 conn:hook("ready", function () |
69 if not opts.quiet then | 69 if not opts.quiet then |
70 io.stderr:write("clix: connected as ", conn.jid, "\n"); | 70 io.stderr:write("clix: connected as ", conn.jid, "\n"); |
71 end | 71 end |
72 if opts.chatroom then | 72 if opts.chatroom then |
73 conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")}); | 73 conn:send(verse.presence{to=opts.to.."/"..(opts.nick or "clix")}); |
75 if opts.presence then | 75 if opts.presence then |
76 conn:send(verse.presence()); | 76 conn:send(verse.presence()); |
77 end | 77 end |
78 return on_connect(conn); | 78 return on_connect(conn); |
79 end); | 79 end); |
80 conn:hook("binding-failure", function (err) | 80 conn:hook("bind-failure", function (err) |
81 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); | 81 conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or "")); |
82 conn:close(); | 82 conn:close(); |
83 end); | 83 end); |
84 conn:hook("disconnected", function (info) | 84 conn:hook("disconnected", function (info) |
85 if info.reason then | 85 if info.reason then |