Software /
code /
verse
Annotate
doc/example_jingle_send.lua @ 494:04c216ac429a
configure: fix --lua-lib-dir
author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
---|---|
date | Fri, 07 Jul 2023 17:23:09 +0700 |
parent | 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 |
260
7f6df45a3d1f
doc/example*.lua: Update to use new .init() method
Matthew Wild <mwild1@gmail.com>
parents:
110
diff
changeset
|
9 require "verse".init("client"); |
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
|
10 |
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 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
|
12 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
|
13 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
|
14 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
|
15 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
|
16 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
|
17 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
|
18 |
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 -- 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
|
20 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
|
21 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
|
22 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
|
23 |
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 -- 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
|
25 --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
|
26 |
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 -- 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
|
28 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
|
29 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
|
30 |
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 -- 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
|
32 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
|
33 |
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 -- 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
|
35 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
|
36 |
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 -- 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
|
38 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
|
39 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
|
40 |
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 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
|
42 :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
|
43 :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
|
44 ); |
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 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
|
47 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
|
48 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
|
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 |
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 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
|
52 verse.loop() |