diff options
author | xengineering <me@xengineering.eu> | 2023-05-18 18:35:53 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-05-18 18:35:53 +0200 |
commit | 0f96bb37005dfda8c2fe20a638f670f6385d2e8b (patch) | |
tree | 616d70cc2127bc0c16235aff4b4fa1c44a20fe69 /limox.go | |
parent | c5cd3e4eafb4fdd10c9bfe0ccac0993beb20f3ee (diff) | |
download | limox-0f96bb37005dfda8c2fe20a638f670f6385d2e8b.tar limox-0f96bb37005dfda8c2fe20a638f670f6385d2e8b.tar.zst limox-0f96bb37005dfda8c2fe20a638f670f6385d2e8b.zip |
Use one bidirectional channel for communication
Diffstat (limited to 'limox.go')
-rw-r--r-- | limox.go | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -27,8 +27,7 @@ type Limox struct { JidEditor widget.Editor PwdEditor widget.Editor MainButton widget.Clickable - XmppEvents chan any - GuiEvents chan xmpp.Event + XmppConn chan any State LimoxState Window *app.Window Operations op.Ops @@ -43,8 +42,7 @@ func NewLimox() Limox { ), Operations: op.Ops{}, Theme: material.NewTheme(gofont.Collection()), - XmppEvents: make(chan any), - GuiEvents: make(chan xmpp.Event), + XmppConn: make(chan any), State: Disconnected, } } @@ -62,7 +60,7 @@ func (l *Limox) run() error { } l.draw(e) } - case ev := <-l.XmppEvents: + case ev := <-l.XmppConn: switch ev.(type) { case error: log.Print(ev) @@ -88,14 +86,14 @@ func (l *Limox) buttonCallback() { switch l.State { case Disconnected: log.Println("Starting connection establishment ...") - go xmpp.Run(l.GuiEvents, l.XmppEvents, l.JidEditor.Text(), l.PwdEditor.Text()) + go xmpp.Run(l.XmppConn, l.JidEditor.Text(), l.PwdEditor.Text()) l.State = Connecting case Connecting: log.Println("Aborted connection establishment") l.State = Disconnected case Connected: log.Println("Disconnecting ...") - l.GuiEvents <- xmpp.ShouldDisconnectEvent + l.XmppConn <- xmpp.ShouldDisconnectEvent l.State = Disconnected } } |