Diff

doc/example_pep.lua @ 269:a15ede6b9ca1

doc/example_pep.lua: Reorder a bit to avoid re-sending presence multiple times when caps change.
author Kim Alvefur <zash@zash.se>
date Fri, 16 Dec 2011 22:09:37 +0100
parent 260:7f6df45a3d1f
line wrap: on
line diff
--- a/doc/example_pep.lua	Fri Dec 16 22:04:03 2011 +0100
+++ b/doc/example_pep.lua	Fri Dec 16 22:09:37 2011 +0100
@@ -9,7 +9,6 @@
 
 c = verse.new();
 c:add_plugin("version");
-c:add_plugin("disco");
 c:add_plugin("pep");
 
 -- Add some hooks for debugging
@@ -33,8 +32,17 @@
 -- Catch the "ready" event to know when the stream is ready to use
 c:hook("ready", function ()
 	print("Stream ready!");
+	c.version:set{ name = "verse example client" };
+	c:hook_pep("http://jabber.org/protocol/mood", function (event)
+		print(event.from.." is "..event.item.tags[1].name);
+	end);
+	
+	c:hook_pep("http://jabber.org/protocol/tune", function (event)
+		print(event.from.." is listening to "..event.item:get_child_text("title"));
+	end);
+
 	c:send(verse.presence());
-	c.version:set{ name = "verse example client" };
+
 	c:publish_pep(verse.stanza("tune", { xmlns = "http://jabber.org/protocol/tune" })
 		:tag("title"):text("Beautiful Cedars"):up()
 		:tag("artist"):text("The Spinners"):up()
@@ -42,13 +50,6 @@
 		:tag("track"):text("4"):up()
 	);
 	
-	c:hook_pep("http://jabber.org/protocol/mood", function (event)
-		print(event.from.." is "..event.item.tags[1].name);
-	end);
-	
-	c:hook_pep("http://jabber.org/protocol/tune", function (event)
-		print(event.from.." is listening to "..event.item:get_child_text("title"));
-	end);
 end);
 
 print("Starting loop...")