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