Changeset

17:fa9efbef8a0c

Move presence sending into clix_connect(), and control with -o/--presence
author Matthew Wild <mwild1@gmail.com>
date Thu, 07 Jan 2010 20:56:18 +0000
parents 16:3a1c076d9382
children 18:6ad3ea055905
files clix.lua clix/receive.lua
diffstat 2 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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