From 0f96bb37005dfda8c2fe20a638f670f6385d2e8b Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 18 May 2023 18:35:53 +0200 Subject: Use one bidirectional channel for communication --- limox.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'limox.go') diff --git a/limox.go b/limox.go index 2dee767..6723745 100644 --- a/limox.go +++ b/limox.go @@ -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 } } -- cgit v1.2.3-70-g09d2