// 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
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
if err == nil || ctx.Err() != nil || !w.retrying || !w.linked {
w.retrying = false
w.mutex.Unlock()
+
return false
}