diff options
Diffstat (limited to 'xmpp/stream_pair.go')
-rw-r--r-- | xmpp/stream_pair.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmpp/stream_pair.go b/xmpp/stream_pair.go index e02cca6..b13d8a3 100644 --- a/xmpp/stream_pair.go +++ b/xmpp/stream_pair.go @@ -9,6 +9,8 @@ func runStreamPair(s *session) { openStream(s) defer closeStream(s) + buf := newElementBuffer() + for { select { case data := <-s.in: @@ -18,8 +20,22 @@ func runStreamPair(s *session) { default: log.Printf("Unknown data '%d'!\n", data) } - case _ = <-s.rx: - // TODO route received XML token here + case t := <-s.rx: + err := buf.add(t) + if err != nil { + log.Printf("Could not add XML token to buffer: %v\n", err) + return + } + if buf.isComplete() { + element := buf.reset() + // TODO handle XML element here - this is just a dummy: + switch start := element[0].(type) { + case xml.StartElement: + log.Printf("Got XML element `%s`\n", start.Name.Local) + default: + log.Println("No xml.StartElement at start of element buffer!") + } + } } } } |