}
// daemonServe runs the loop that start makes and serves the clients of listener
-// until ctx ends or the loop fails. It closes listener. It keeps whatsapp
-// connected. When bot is not nil, it runs the bot too, and a failure of the bot
+// until ctx ends or the loop fails. It closes listener. It runs whatsapp, which
+// logs its notes in the loop and tells all clients its notices. When bot is not nil, it runs the bot too, and a failure of the bot
// stops the agent.
func daemonServe(ctx context.Context, listener net.Listener, bot *TelegramBot, whatsapp *WhatsApp, start func(notify func(Event)) (*TurnLoop, error)) error {
ctx, cancel := context.WithCancel(ctx)
go func() {
defer workers.Done()
- whatsapp.Run(ctx)
+ whatsapp.Run(ctx, l, notify)
}()
var botErr error