Closed lofti198 closed 6 months ago
I'm not familiar with IStreamStorage so I can't tell if it fits the job.
The recommended method if you don't have access to files is to save session to DB, like in this example: https://github.com/wiz0u/WTelegramClient/blob/master/Examples/Program_Heroku.cs?ts=4#L61
I saw this example, I just didn't really get - how exactly in this case the config parameters (like api_id) are sent. I mean, how to implement initial authentication.
As for StreamStorage, it is just simple stream storage, based on concurrent dictionary (so that each user (phone) had their own stream with session) https://github.com/lofti198/TelegramReadChannel/blob/master/TelegramReadChannel/InMemoryStreamStorage.cs
I'm not going to review your whole code because it's not my job. but obviously your SaveStreamAsync is badly implemented, either rewind the stream before save, or cast original stream back to MemoryStream then ToArray()
Oh, I am sorry for misleading you. I just wanted to understand: if we use stream instead of file - how to pass config parameters inside client constructor? Is this the correct way to call the constructor?
using var client = new WTelegram.Client(Config, sessionStore);
Thank you in advance! And once more thank you for your amazing library!
Yes. See also the README
I use library on server (asp net 8 webapi) thats why I cannot save session to file. I ve googled for the solution and ended up with code below. But it seems that when I am doing the second run (after the first which triggered sending verification code SMS) and trying to pass the code as
request.VerificationCode;
it doesn't recognize it.When I used files, everything worked as needed:
So my current code below. What should I do to correctly save session in stream?