Auties00 / Cobalt

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

Is there an ability to handle multiple accounts in multithreads? #504

Closed SachukS closed 5 days ago

SachukS commented 1 week ago

I'm developing Java Spring server for telegram and whatsapp messengers, and i want to know is there an ability to handle multiple whatsapp accounts in one time? Thanks for your work

Darker935 commented 1 week ago

I think if you change this code:

.newConnection().name("YourSessionName")

on your login logic, you can operate with more than 1 session per time. Try and report

that's an exapmle of login (after register):

var whatsapp = mobileBuilder()
    .newConnection()
    .name("Account-1")
    .device(CompanionDevice.ios(false))
    .autodetectListeners(true)
    .registered()
    .orElseThrow();
Darker935 commented 1 week ago

It worked?

SachukS commented 6 days ago

It worked?

Yea, it worked in such way. Sorry for late response, was busy with another staff

Darker935 commented 5 days ago

No problem! If you have no further questions, you can close the issue now

SachukS commented 4 days ago

I think if you change this code:

.newConnection().name("YourSessionName")

on your login logic, you can operate with more than 1 session per time. Try and report

that's an exapmle of login (after register):

var whatsapp = mobileBuilder()
    .newConnection()
    .name("Account-1")
    .device(CompanionDevice.ios(false))
    .autodetectListeners(true)
    .registered()
    .orElseThrow();

After deep testing i've found better way to implement functional i need:

Whatsapp api = Whatsapp.webBuilder()
                    .newConnection(partner.getPhone())
                    .name("your messenger tool name")
                    .unregistered(onQRCode());