summaryrefslogtreecommitdiff
path: root/xmpp/session.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2023-07-03 22:28:01 +0200
committerxengineering <me@xengineering.eu>2023-07-03 22:28:01 +0200
commit3efcd60f8ebdc962d5be85003cc8c59a2b43e610 (patch)
tree9f53b6a0895e244e228dbbfa3baa59f4a05957e6 /xmpp/session.go
parent2fade1039c1842f08b30da5c95b5542b57e38ec6 (diff)
downloadlimox-3efcd60f8ebdc962d5be85003cc8c59a2b43e610.tar
limox-3efcd60f8ebdc962d5be85003cc8c59a2b43e610.tar.zst
limox-3efcd60f8ebdc962d5be85003cc8c59a2b43e610.zip
Remove encoderDecoder struct completely
This was not really necessary because it was all related to the xmpp.session and should thus be implemented there. Using the context package further reduced the complexity for cancelation.
Diffstat (limited to 'xmpp/session.go')
-rw-r--r--xmpp/session.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/xmpp/session.go b/xmpp/session.go
index b4a8fab..6a5e646 100644
--- a/xmpp/session.go
+++ b/xmpp/session.go
@@ -1,6 +1,7 @@
package xmpp
import (
+ "context"
"crypto/tls"
"crypto/x509"
"encoding/xml"
@@ -18,7 +19,6 @@ type session struct {
in chan any
out chan<- any
transport *tls.Conn
- ed encoderDecoder
tx *xml.Encoder
rx chan xml.Token
resourceReq string
@@ -47,9 +47,10 @@ func (s *session) run() {
}
defer s.transport.Close()
- s.ed = newEncoderDecoder(s)
- go s.ed.run()
- defer func() { s.ed.terminator <- true }()
+ ctx, cancel := context.WithCancel(context.Background())
+ cpy := s.rx
+ go runRx(ctx, cpy, s.transport)
+ defer cancel()
lw := logger{"[TX] "}
w := io.MultiWriter(s.transport, lw)