xmppstream.lua

changeset 3
ab02540afcf3
parent 0
319733864f05
equal deleted inserted replaced
2:c04d4fd34685 3:ab02540afcf3
75 end 75 end
76 end 76 end
77 77
78 if not stanza then --if we are not currently inside a stanza 78 if not stanza then --if we are not currently inside a stanza
79 if session.notopen then 79 if session.notopen then
80 if tagname == stream_tag then 80 if cb_streamopened then
81 if cb_streamopened then 81 cb_streamopened(session, attr, name);
82 cb_streamopened(session, attr);
83 end
84 else
85 -- Garbage before stream?
86 cb_error(session, "no-stream");
87 end 82 end
88 return; 83 return;
89 end 84 end
90 if curr_ns == "jabber:client" and name ~= "iq" and name ~= "presence" and name ~= "message" then
91 cb_error(session, "invalid-top-level-element");
92 end
93
94 stanza = st.stanza(name, attr); 85 stanza = st.stanza(name, attr);
95 else -- we are inside a stanza, so add a tag 86 else -- we are inside a stanza, so add a tag
96 attr.xmlns = nil; 87 attr.xmlns = nil;
97 if curr_ns ~= stream_default_ns then 88 if curr_ns ~= stream_default_ns then
98 attr.xmlns = curr_ns; 89 attr.xmlns = curr_ns;
122 stanza = nil; 113 stanza = nil;
123 else 114 else
124 stanza:up(); 115 stanza:up();
125 end 116 end
126 else 117 else
127 if tagname == stream_tag then 118 if cb_streamclosed then
128 if cb_streamclosed then 119 cb_streamclosed(session);
129 cb_streamclosed(session);
130 end
131 else
132 local curr_ns,name = tagname:match(ns_pattern);
133 if name == "" then
134 curr_ns, name = "", curr_ns;
135 end
136 cb_error(session, "parse-error", "unexpected-element-close", name);
137 end 120 end
138 stanza, chardata = nil, {}; 121 stanza, chardata = nil, {};
139 end 122 end
140 end 123 end
141 124

mercurial