Move presence sending into clix_connect(), and control with -o/--presence

Thu, 07 Jan 2010 20:56:18 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 07 Jan 2010 20:56:18 +0000
changeset 17
fa9efbef8a0c
parent 16
3a1c076d9382
child 18
6ad3ea055905

Move presence sending into clix_connect(), and control with -o/--presence

clix.lua file | annotate | diff | comparison | revisions
clix/receive.lua file | annotate | diff | comparison | revisions
--- a/clix.lua	Thu Jan 07 19:50:22 2010 +0000
+++ b/clix.lua	Thu Jan 07 20:56:18 2010 +0000
@@ -9,7 +9,7 @@
 require "verse.client"
 
 -- Global to allow commands to add to it
-short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", p = "password", r = "resource" }
+short_opts = { v = "verbose", t = "to", f = "from", e = "type", a = "account", p = "password", r = "resource", o = "presence" }
 
 local command = arg[1];
 
@@ -67,7 +67,13 @@
 		conn:error("Authentication failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
 		conn:close();
 	end);
-	conn:hook("binding-success", function () conn:debug("Connected: "..tostring(conn)); return on_connect(conn); end);
+	conn:hook("binding-success", function ()
+		conn:debug("Connected: "..tostring(conn));
+		if opts.presence then
+			conn:send(verse.presence());
+		end
+		return on_connect(conn);
+	end);
 	conn:hook("binding-failure", function (err)
 		conn:error("Resource binding failure ("..(err.condition or "unknown error")..")"..(err.text and (": "..err.text) or ""));
 		conn:close();
--- a/clix/receive.lua	Thu Jan 07 19:50:22 2010 +0000
+++ b/clix/receive.lua	Thu Jan 07 20:56:18 2010 +0000
@@ -7,7 +7,6 @@
 	end
 	local function on_connect(conn)
 		conn:hook("message", on_message);
-		conn:send(verse.presence());
 	end
 	clix_connect(opts, on_connect);
 end

mercurial