Auties00 / Cobalt

Standalone unofficial fully-featured Whatsapp Web and Mobile API for Java and Kotlin
MIT License
611 stars 179 forks source link

Cannot generate QRCode from example #478

Closed ImPabl0 closed 2 months ago

ImPabl0 commented 2 months ago

Hi, i tried to login using the example code but nothings happen, the proccess is not waiting for WhatsappConnection.

import it.auties.whatsapp.api.QrHandler;
import it.auties.whatsapp.api.Whatsapp;

class Main{
    public static void main(String[] args){
        Whatsapp whatsapp = Whatsapp.webBuilder()
                .lastConnection()
                .unregistered(QrHandler.toTerminal())
                .addActionListener(((action, messageIndexInfo) -> {
                    System.out.println("Action: " + action + " Message: " + messageIndexInfo);
                }))
                .addLoggedInListener(()->{
                    System.out.println("Connected");
                }).connect().join();

}}

I'm using Oracle JDK 21.0.2 and version 0.0.5 from Cobalt

output:

Connected to the target VM, address: '127.0.0.1:64572', transport: 'socket'
Disconnected from the target VM, address: '127.0.0.1:64572', transport: 'socket'

Process finished with exit code 0
Auties00 commented 2 months ago

Add .awaitDisconnection();

ImPabl0 commented 2 months ago

Working now! Thanks <3