diff options
-rw-r--r-- | xmpp/encoder_decoder.go | 3 | ||||
-rw-r--r-- | xmpp/session.go | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/xmpp/encoder_decoder.go b/xmpp/encoder_decoder.go index c8ccd89..7a917da 100644 --- a/xmpp/encoder_decoder.go +++ b/xmpp/encoder_decoder.go @@ -65,7 +65,8 @@ func (ed *encoderDecoder) run() { if err != nil { log.Println("Could not encode to server stream log") } err = ed.sl.Flush() if err != nil { log.Println("Could not flush server stream log") } - _ = xml.CopyToken(t) // TODO do something meaningful here + c := xml.CopyToken(t) + ed.session.rx <- c } if err != nil { if errors.Is(err, io.EOF) { return } diff --git a/xmpp/session.go b/xmpp/session.go index 080fb21..2162d66 100644 --- a/xmpp/session.go +++ b/xmpp/session.go @@ -17,6 +17,7 @@ type session struct { transport *tls.Conn ed encoderDecoder streams []stream + rx chan xml.Token } func StartSession(out chan any, jid string, pwd string) chan any { @@ -26,6 +27,7 @@ func StartSession(out chan any, jid string, pwd string) chan any { s.in = make(chan any) s.out = out s.streams = make([]stream, 0) + s.rx = make(chan xml.Token, 0) go s.run() @@ -55,6 +57,8 @@ func (s *session) run() { case SessionShouldDisconnect: return default: log.Printf("Unknown data '%d'!\n", data) } + case _ = <-s.rx: + // TODO route received XML token here } } } |