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 /limox.go | |
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 'limox.go')
-rw-r--r-- | limox.go | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -25,8 +25,7 @@ type Limox struct { JidEditor widget.Editor PwdEditor widget.Editor MainButton widget.Clickable - sessionIn chan<- any - sessionOut chan any + frontend xmpp.SessionFrontend State LimoxState Window *app.Window Operations op.Ops @@ -41,7 +40,6 @@ func NewLimox() Limox { ), Operations: op.Ops{}, Theme: material.NewTheme(), - sessionOut: make(chan any), State: Disconnected, } @@ -64,7 +62,7 @@ func (l *Limox) run() error { } l.draw(e) } - case data := <-l.sessionOut: + case data := <-l.frontend.In: switch data.(type) { case xmpp.SessionDisconnect: l.State = Disconnected @@ -79,20 +77,19 @@ func (l *Limox) run() error { } func (l *Limox) buttonCallback() { - c := l.sessionIn switch l.State { case Disconnected: jid := l.JidEditor.Text() pwd := l.PwdEditor.Text() setLastJid(jid) setLastPwd(pwd) - l.sessionIn = xmpp.StartSession(l.sessionOut, jid, pwd) + l.frontend = xmpp.StartSession(jid, pwd) l.State = Connecting case Connecting: - go func() { c <- xmpp.SessionShouldDisconnect{} }() + go func() { l.frontend.Out <- xmpp.SessionShouldDisconnect{} }() l.State = Disconnected case Connected: - go func() { c <- xmpp.SessionShouldDisconnect{} }() + go func() { l.frontend.Out <- xmpp.SessionShouldDisconnect{} }() l.State = Disconnected } } |