30 end |
30 end |
31 return true; |
31 return true; |
32 end |
32 end |
33 |
33 |
34 function stream_callbacks.streamclosed(stream) |
34 function stream_callbacks.streamclosed(stream) |
35 if not stream.notopen then |
35 stream.notopen = true; |
|
36 if not stream.closed then |
36 stream:send("</stream:stream>"); |
37 stream:send("</stream:stream>"); |
37 stream.notopen = true; |
38 stream.closed = true; |
38 end |
39 end |
39 stream:event("closed"); |
40 stream:event("closed"); |
40 return stream:close("stream closed") |
41 return stream:close("stream closed") |
41 end |
42 end |
42 |
43 |
133 self:hook("bind-success", stream_ready, -1); |
134 self:hook("bind-success", stream_ready, -1); |
134 |
135 |
135 local _base_close = self.close; |
136 local _base_close = self.close; |
136 function self:close(reason) |
137 function self:close(reason) |
137 self.close = _base_close; |
138 self.close = _base_close; |
138 if not self.notopen then |
139 if not self.closed then |
139 self:send("</stream:stream>"); |
140 self:send("</stream:stream>"); |
140 self.notopen = true; |
141 self.closed = true; |
141 else |
142 else |
142 return self:close(reason); |
143 return self:close(reason); |
143 end |
144 end |
144 end |
145 end |
145 |
146 |