Comparison

doc/example_jingle_send.lua @ 110:3fca7dd127df

doc/example_jingle.lua, doc/example_jingle_send.lua: Example scripts to receive and send files using Jingle
author Matthew Wild <mwild1@gmail.com>
date Tue, 24 Aug 2010 11:16:46 +0100
child 260:7f6df45a3d1f
comparison
equal deleted inserted replaced
109:60a03b2cabec 110:3fca7dd127df
1 -- Change these:
2 local jid, password = "user@example.com/sender", "secret";
3 local receiver = "user@example.com/receiver";
4
5 -- This line squishes verse each time you run,
6 -- handy if you're hacking on Verse itself
7 --os.execute("squish --minify-level=none");
8
9 require "verse" -- Verse main library
10 require "verse.client" -- XMPP client library
11
12 c = verse.new(verse.logger())
13 c:add_plugin("version");
14 c:add_plugin("disco");
15 c:add_plugin("proxy65");
16 c:add_plugin("jingle");
17 c:add_plugin("jingle_ft");
18 c:add_plugin("jingle_s5b");
19
20 -- Add some hooks for debugging
21 c:hook("opened", function () print("Stream opened!") end);
22 c:hook("closed", function () print("Stream closed!") end);
23 c:hook("stanza", function (stanza) print("Stanza:", stanza) end, 15);
24
25 -- This one prints all received data
26 --c:hook("incoming-raw", function (...) print("<<", ...) end, 1000);
27
28 -- Print a message after authentication
29 c:hook("authentication-success", function () print("Logged in!"); end);
30 c:hook("authentication-failure", function (err) print("Failed to log in! Error: "..tostring(err.condition)); end);
31
32 -- Print a message and exit when disconnected
33 c:hook("disconnected", function () print("Disconnected!"); os.exit(); end);
34
35 -- Now, actually start the connection:
36 c:connect_client(jid, password);
37
38 -- Catch the "ready" event to know when the stream is ready to use
39 c:hook("ready", function ()
40 print("Stream ready!");
41
42 c:send(verse.presence()
43 :tag("status"):text("Let me send you a file!"):up()
44 :add_child(c:caps())
45 );
46
47 c:hook("proxy65/discovered-proxies", function ()
48 print(c:send_file(receiver, "jingle.txt"));
49 end);
50 end);
51
52 print("Starting loop...")
53 verse.loop()