# HG changeset patch # User Kim Alvefur # Date 1324069777 -3600 # Node ID a15ede6b9ca11f48e00a93ef0ab7a390da28b241 # Parent 06e6c6de643871600f7eceaed9c2e7bc94a4cca8 doc/example_pep.lua: Reorder a bit to avoid re-sending presence multiple times when caps change. diff -r 06e6c6de6438 -r a15ede6b9ca1 doc/example_pep.lua --- 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...")