tdlight-team / tdlight-java

Complete Bot and Userbot Telegram library based on TDLib
https://t.me/TDLight
GNU Lesser General Public License v3.0
263 stars 43 forks source link

Async managing more than 1 client #219

Open SachukS opened 4 months ago

SachukS commented 4 months ago

Hi, I'm writing Spring Boot server using tdlight. I want to implement the logic of simultaneous management of telegram clients. For example, a user logs into my app, then logs into Telegram and uses it. At the same time, another user logs into the application and creates a Telegram client. Now I have implemented separate threads of execution for each user in a spring boot, and in them I initialize the Telegram clients, but when the second user logs in, the first user receives the second user's Telegram client. In the next logs you can see that there is on tdlib thread for all created clients: 2024-07-05T12:12:20.932+03:00 ERROR 21192 --- [pool-3-thread-1] c.h.TEST.telegram.client.Telegram : Telegram constructor 2024-07-05T12:12:31.287+03:00 ERROR 21192 --- [pool-3-thread-1] c.h.TEST.telegram.client.Telegram : Telegram login 2024-07-05T12:12:31.315+03:00 INFO 21192 --- [pool-3-thread-1] it.tdlight.TelegramClient : Registered new client 1 2024-07-05T12:12:31.352+03:00 INFO 21192 --- [ TDLib thread] c.h.TEST.telegram.client.Telegram : Logged in Telegram 2024-07-05T12:12:31.745+03:00 ERROR 21192 --- [ TDLib thread] c.h.TEST.telegram.client.Telegram : Telegram on new message 2024-07-05T12:12:31.747+03:00 ERROR 21192 --- [ TDLib thread] c.h.TEST.telegram.client.Telegram : Telegram on new message

So, is there ability to implement logic i want, and if yes - how?

zybot666 commented 4 months ago

How to implement different account logins,The user enters the login verification code and how the program receives it?

SachukS commented 4 months ago

How to implement different account logins,The user enters the login verification code and how the program receives it?

I'm using QR codes, and i have websockets between my front and back to handle QR codes

zybot666 commented 4 months ago

How to implement different account logins,The user enters the login verification code and how the program receives it?

I'm using QR codes, and i have websockets between my front and back to handle QR codes

fine,do you set the different database catalog ?

zybot666 commented 4 months ago

i wang to user use phonenumber log in tdlib but i don't know how to receive the user's log in code

SachukS commented 4 months ago

i wang to user use phonenumber log in tdlib but i don't know how to receive the user's log in code

i have answered in your issue

SachukS commented 4 months ago

How to implement different account logins,The user enters the login verification code and how the program receives it?

I'm using QR codes, and i have websockets between my front and back to handle QR codes

fine,do you set the different database catalog ?

not database, but different folder

zybot666 commented 4 months ago

i wang to user use phonenumber log in tdlib but i don't know how to receive the user's log in code

i have answered in your issue

Ok, thank you. Your skills are much higher than mine.