X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/53c6c8a5a17e2dfc8bd3ff02ab99d29d709dda2f..a3b9849a54a6cd8a4cc5b1ae03a39aab31322f7b:/whatsapp.go?ds=inline diff --git a/whatsapp.go b/whatsapp.go index e02e8c6..b076708 100644 --- a/whatsapp.go +++ b/whatsapp.go @@ -209,10 +209,10 @@ type WhatsApp struct { // failed first connection starts the same outage notice as a lost connection. A // timer in the select retries it with a doubled wait from 2 seconds to 5 // minutes, without a retry goroutine or a wait that blocks commands or the -// inbox. A connection, unlink, logout, pair command, or ctx end stops retries. -// The library owns retries after a connection opens. Run returns the error of a -// write of the log or of the state file, which stops the daemon, because then -// messages would be lost. +// inbox. A connection, unlink, logout, or ctx end stops retries. The library +// owns retries after a connection opens. Run returns the error of a write of +// the log or of the state file, which stops the daemon, because then messages +// would be lost. func (w *WhatsApp) Run(ctx context.Context, l *TurnLoop, notify func(Event)) error { w.mutex.Lock() w.notify = notify @@ -277,13 +277,13 @@ func (w *WhatsApp) Run(ctx context.Context, l *TurnLoop, notify func(Event)) err return err } case request := <-w.requests: - stopRetry() cancel() pairing.Wait() cancel = func() {} switch { case request.unlink: + stopRetry() err = w.unlink(ctx, l, request.answer) if err != nil { return err @@ -459,6 +459,7 @@ func (w *WhatsApp) connect(ctx context.Context) bool { if err == nil || ctx.Err() != nil || !w.retrying || !w.linked { w.retrying = false w.mutex.Unlock() + return false }