Auties00 / Cobalt

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

How to terminate connection while registering? #262

Closed savox-326 closed 1 year ago

savox-326 commented 1 year ago

I mean when QR codes send while you not connected to your account how terminate connection

Auties00 commented 1 year ago

I mean when QR codes send while you not connected to your account how terminate connection

Use the disconnect method from the api

savox-326 commented 1 year ago

@Auties00 but if i have this on setup whatsapp = Whatsapp.newConnection(createOptions()) .addLoggedInListener { -> successConnect() } .connect() .get()

and run whatsapp.disconnect() on other thread (for not blocking program) i got something about this "cannot invoke method disconnect() because whatsapp is null"

Auties00 commented 1 year ago

@Auties00 but if i have this on setup whatsapp = Whatsapp.newConnection(createOptions()) .addLoggedInListener { -> successConnect() } .connect() .get()

and run whatsapp.disconnect() on other thread (for not blocking program) i got something about this "cannot invoke method disconnect() because whatsapp is null"

Use the api instance coming from the listener, the instance you are using will be unitialized