diff options
Diffstat (limited to 'xmpp/stream_pair.go')
-rw-r--r-- | xmpp/stream_pair.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/xmpp/stream_pair.go b/xmpp/stream_pair.go index 5674d7b..f1de345 100644 --- a/xmpp/stream_pair.go +++ b/xmpp/stream_pair.go @@ -6,8 +6,8 @@ import ( ) func runStreamPair(s *session) { - openStream(s) - defer closeStream(s) + end := openStream(s) + defer closeStream(s, end) buf := newElementBuffer() @@ -34,7 +34,7 @@ func runStreamPair(s *session) { } } -func openStream(s *session) { +func openStream(s *session) xml.EndElement { start := xml.StartElement{ xml.Name{"jabber:client", "stream:stream"}, []xml.Attr{ @@ -45,8 +45,7 @@ func openStream(s *session) { xml.Attr{xml.Name{"", "xmlns:stream"}, "http://etherx.jabber.org/streams"}, }, } - - s.streamEnd = start.End() + end := start.End() err := s.ed.encodeToken(start) if err != nil { @@ -54,6 +53,8 @@ func openStream(s *session) { } syncStreams(s) + + return end } // syncStreams drops XML tokens from the receiving stream until an @@ -84,8 +85,8 @@ func syncStreams(s *session) { } } -func closeStream(s *session) { - err := s.ed.encodeToken(s.streamEnd) +func closeStream(s *session, end xml.EndElement) { + err := s.ed.encodeToken(end) if err != nil { log.Println("Could not encode stream end!") } |