diff options
author | xengineering <me@xengineering.eu> | 2023-09-04 22:18:53 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-09-04 22:44:00 +0200 |
commit | 93668403433cbfc22fe9c38ebbd6ef67af625ad2 (patch) | |
tree | 199446aaaac5d1ac1c6947494008bf10c2d333a9 /xmpp | |
parent | 44bc88197196df41ead0ede734295cb2feac066d (diff) | |
download | limox-93668403433cbfc22fe9c38ebbd6ef67af625ad2.tar limox-93668403433cbfc22fe9c38ebbd6ef67af625ad2.tar.zst limox-93668403433cbfc22fe9c38ebbd6ef67af625ad2.zip |
xmpp: Add type SessionFrontend
Some parts of the `xmpp` module functionality should be written for the
using application software. To reference a running session more easily
it is an advantage to have an opaque struct for this instead of
decoupled channels.
Diffstat (limited to 'xmpp')
-rw-r--r-- | xmpp/session.go | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/xmpp/session.go b/xmpp/session.go index 4dfd76f..ad90c5e 100644 --- a/xmpp/session.go +++ b/xmpp/session.go @@ -13,29 +13,34 @@ type SessionConnect struct{} type SessionDisconnect struct{} type SessionShouldDisconnect struct{} +type SessionFrontend struct { + In chan any + Out chan any +} + type session struct { jid string pwd string in chan any - out chan<- any + out chan any transport *tls.Conn tx *xml.Encoder rx chan any resourceReq string } -func StartSession(out chan<- any, jid string, pwd string) (in chan<- any) { +func StartSession(jid string, pwd string) (SessionFrontend) { s := session{} s.jid = jid s.pwd = pwd s.in = make(chan any) - s.out = out + s.out = make(chan any) s.rx = make(chan any, 0) go s.run() - return s.in + return SessionFrontend{s.out, s.in} } func (s *session) run() { |