Software /
code /
verse
Annotate
component.lua @ 506:3610196c5e83 default tip
Merge with Zash.
author | Trần H. Trung <xmpp:trần.h.trung@trung.fun> |
---|---|
date | Sat, 08 Jul 2023 02:17:52 +0700 |
parent | 490:6b2f31da9610 |
rev | line source |
---|---|
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local verse = require "verse"; |
485
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
2 local stream_mt = verse.stream_mt; |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 |
490
6b2f31da9610
Update for new Prosody module namespace
Kim Alvefur <zash@zash.se>
parents:
485
diff
changeset
|
4 local jid_split = require "prosody.util.jid".split; |
6b2f31da9610
Update for new Prosody module namespace
Kim Alvefur <zash@zash.se>
parents:
485
diff
changeset
|
5 local st = require "prosody.util.stanza"; |
6b2f31da9610
Update for new Prosody module namespace
Kim Alvefur <zash@zash.se>
parents:
485
diff
changeset
|
6 local sha1 = require "prosody.util.hashes".sha1; |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 -- Shortcuts to save having to load util.stanza |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 verse.message, verse.presence, verse.iq, verse.stanza, verse.reply, verse.error_reply = |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 st.message, st.presence, st.iq, st.stanza, st.reply, st.error_reply; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 |
490
6b2f31da9610
Update for new Prosody module namespace
Kim Alvefur <zash@zash.se>
parents:
485
diff
changeset
|
12 local new_xmpp_stream = require "prosody.util.xmppstream".new; |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 local xmlns_stream = "http://etherx.jabber.org/streams"; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 local xmlns_component = "jabber:component:accept"; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 local stream_callbacks = { |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 stream_ns = xmlns_stream, |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 stream_tag = "stream", |
150
728cc7f2f0c2
verse.component: Namespacing fixes
Matthew Wild <mwild1@gmail.com>
parents:
84
diff
changeset
|
20 default_ns = xmlns_component }; |
411 | 21 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 function stream_callbacks.streamopened(stream, attr) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 stream.stream_id = attr.id; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 if not stream:event("opened", attr) then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 stream.notopen = nil; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 return true; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 function stream_callbacks.streamclosed(stream) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 return stream:event("closed"); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 function stream_callbacks.handlestanza(stream, stanza) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 if stanza.attr.xmlns == xmlns_stream then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 return stream:event("stream-"..stanza.name, stanza); |
150
728cc7f2f0c2
verse.component: Namespacing fixes
Matthew Wild <mwild1@gmail.com>
parents:
84
diff
changeset
|
37 elseif stanza.attr.xmlns or stanza.name == "handshake" then |
728cc7f2f0c2
verse.component: Namespacing fixes
Matthew Wild <mwild1@gmail.com>
parents:
84
diff
changeset
|
38 return stream:event("stream/"..(stanza.attr.xmlns or xmlns_component), stanza); |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 return stream:event("stanza", stanza); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 |
485
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
44 function stream_mt:connect_component(jid, pass) |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 self.jid, self.password = jid, pass; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 self.username, self.host, self.resource = jid_split(jid); |
411 | 47 |
485
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
48 -- Component stream methods |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
49 function self:reset() |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
50 if self.stream then |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
51 self.stream:reset(); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
52 else |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
53 self.stream = new_xmpp_stream(self, stream_callbacks); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
54 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
55 self.notopen = true; |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
56 return true; |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
57 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
58 |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
59 function self:reopen() |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
60 self:reset(); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
61 self:send(st.stanza("stream:stream", { to = self.jid, ["xmlns:stream"]='http://etherx.jabber.org/streams', |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
62 xmlns = xmlns_component, version = "1.0" }):top_tag()); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
63 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
64 |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
65 function self:close(reason) |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
66 if not self.notopen then |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
67 self:send("</stream:stream>"); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
68 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
69 local on_disconnect = self.conn.disconnect(); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
70 self.conn:close(); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
71 on_disconnect(conn, reason); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
72 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
73 |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
74 function self:send_iq(iq, callback) |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
75 local id = self:new_id(); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
76 self.tracked_iqs[id] = callback; |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
77 iq.attr.id = id; |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
78 self:send(iq); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
79 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
80 |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
81 function self:new_id() |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
82 self.curr_id = self.curr_id + 1; |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
83 return tostring(self.curr_id); |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
84 end |
c9a144591649
component: Avoid adding to the global stream metatable
Matthew Wild <mwild1@gmail.com>
parents:
411
diff
changeset
|
85 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 function self.data(conn, data) |
161
b177bcea2006
squishy, verse.client, verse.component, verse.bosh: Port to util.xmppstream instead of xmlhandlers which has been removed from Prosody. Also remove util.ztact from squishy for the same reason.
Matthew Wild <mwild1@gmail.com>
parents:
150
diff
changeset
|
87 local ok, err = self.stream:feed(data); |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 if ok then return; end |
400
0db9cb909cf1
client, component: Fix logging of invalid XML
Matthew Wild <mwild1@gmail.com>
parents:
314
diff
changeset
|
89 stream:debug("Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " ")); |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 stream:close("xml-not-well-formed"); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 end |
411 | 92 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 self:hook("incoming-raw", function (data) return self.data(self.conn, data); end); |
411 | 94 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 self.curr_id = 0; |
411 | 96 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 self.tracked_iqs = {}; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 self:hook("stanza", function (stanza) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 local id, type = stanza.attr.id, stanza.attr.type; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 if id and stanza.name == "iq" and (type == "result" or type == "error") and self.tracked_iqs[id] then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 self.tracked_iqs[id](stanza); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 self.tracked_iqs[id] = nil; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 return true; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 end); |
411 | 106 |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 self:hook("stanza", function (stanza) |
282
52b971d9ebc3
client, component: `ret` was probably meant to be a local
Kim Alvefur <zash@zash.se>
parents:
161
diff
changeset
|
108 local ret; |
84
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 if stanza.attr.xmlns == nil or stanza.attr.xmlns == "jabber:client" then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 if stanza.name == "iq" and (stanza.attr.type == "get" or stanza.attr.type == "set") then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 if xmlns then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 ret = self:event("iq/"..xmlns, stanza); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 if not ret then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 ret = self:event("iq", stanza); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 if ret == nil then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 self:send(verse.error_reply(stanza, "cancel", "service-unavailable")); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 return true; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 else |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 ret = self:event(stanza.name, stanza); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 return ret; |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 end, -1); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 self:hook("opened", function (attr) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 print(self.jid, self.stream_id, attr.id); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 local token = sha1(self.stream_id..pass, true); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 self:send(st.stanza("handshake", { xmlns = xmlns_component }):text(token)); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 self:hook("stream/"..xmlns_component, function (stanza) |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 if stanza.name == "handshake" then |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 self:event("authentication-success"); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 end); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 end); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 local function stream_ready() |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 self:event("ready"); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 self:hook("authentication-success", stream_ready, -1); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
146 -- Initialise connection |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
147 self:connect(self.connect_host or self.host, self.connect_port or 5347); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
148 self:reopen(); |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
149 end |
d85d2443478e
verse.component: XEP-0114 support \o/
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
150 |