mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2026-01-02 22:59:56 +01:00
Fix infinite recursion on Dispose (#274) 🎬Take 2
This commit is contained in:
parent
15b6346d2a
commit
9315913519
2
.github/dev.yml
vendored
2
.github/dev.yml
vendored
|
|
@ -1,7 +1,7 @@
|
|||
pr: none
|
||||
trigger: [ master ]
|
||||
|
||||
name: 4.1.8-dev.$(Rev:r)
|
||||
name: 4.1.9-dev.$(Rev:r)
|
||||
|
||||
pool:
|
||||
vmImage: ubuntu-latest
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ These two fields derive from class `Peer` and can be of type `PeerChat`, `PeerCh
|
|||
|
||||
The root structure where you obtained the message (typically `UpdatesBase` or `Messages_MessagesBase`) inherits from `IPeerResolver`.
|
||||
This allows you to call `.UserOrChat(peer)` on the root structure, in order to resolve those fields into a `User` class, or a `ChatBase`-derived class
|
||||
(typically `Chat` or `Channel`) which will give you details about the peer, instead of just the ID.
|
||||
(typically `Chat` or `Channel`) which will give you details about the peer, instead of just the ID, and can be implicitly converted to `InputPeer`.
|
||||
|
||||
However, in some case _(typically when dealing with updates)_, Telegram might choose to not include details about a peer
|
||||
because it expects you to already know about it (`UserOrChat` returns `null`).
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
[](https://corefork.telegram.org/methods)
|
||||
[](https://www.nuget.org/packages/WTelegramClient/)
|
||||
[](https://www.nuget.org/packages/WTelegramClient/absoluteLatest)
|
||||
[](https://www.buymeacoffee.com/wizou)
|
||||
[](https://buymeacoffee.com/wizou)
|
||||
|
||||
## *_Telegram Client API library written 100% in C# and .NET_*
|
||||
|
||||
This library allows you to connect to Telegram and control a user programmatically (or a bot, but [WTelegramBot](https://www.nuget.org/packages/WTelegramBot) is much easier for that).
|
||||
All the Telegram Client APIs (MTProto) are supported so you can do everything the user could do with a full Telegram GUI client.
|
||||
|
||||
Library was developed solely by one unemployed guy. [Donations are welcome](https://buymeacoffee.com/wizou).
|
||||
|
||||
This ReadMe is a **quick but important tutorial** to learn the fundamentals about this library. Please read it all.
|
||||
|
||||
> ⚠️ This library requires understanding advanced C# techniques such as **asynchronous programming** or **subclass pattern matching**...
|
||||
|
|
@ -202,6 +204,6 @@ as well as the [API Terms of Service](https://core.telegram.org/api/terms) or yo
|
|||
If you read all this ReadMe, the [Frequently Asked Questions](https://wiz0u.github.io/WTelegramClient/FAQ),
|
||||
the [Examples codes](https://wiz0u.github.io/WTelegramClient/EXAMPLES) and still have questions, feedback is welcome in our Telegram group [@WTelegramClient](https://t.me/WTelegramClient)
|
||||
|
||||
If you like this library, you can [buy me a coffee](https://www.buymeacoffee.com/wizou) ❤ This will help the project keep going.
|
||||
If you like this library, you can [buy me a coffee](https://buymeacoffee.com/wizou) ❤ This will help the project keep going.
|
||||
|
||||
© 2024 Olivier Marcoux
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ namespace WTelegram
|
|||
return dcSession; // if we have already a session with this DC and we are connected or it is a perfect match, use it
|
||||
if (dcSession == null && _session.DCSessions.TryGetValue(-dcId, out dcSession) && dcSession.AuthKey != null)
|
||||
{
|
||||
// we have already negociated an AuthKey with this DC
|
||||
if (dcSession.DataCenter.flags == flags && _session.DCSessions.Remove(-dcId))
|
||||
return _session.DCSessions[dcId] = dcSession; // we found a misclassed DC, change its sign
|
||||
dcSession = new Session.DCSession { Id = Helpers.RandomLong(), // clone AuthKey for a session on the matching media_only DC
|
||||
|
|
@ -872,9 +873,11 @@ namespace WTelegram
|
|||
var triedEndpoints = new HashSet<IPEndPoint> { endpoint };
|
||||
if (_session.DcOptions != null)
|
||||
{
|
||||
var altOptions = _session.DcOptions.Where(dco => dco.id == _dcSession.DataCenter.id && dco.flags != _dcSession.DataCenter.flags
|
||||
&& (dco.flags & (DcOption.Flags.cdn | DcOption.Flags.tcpo_only | DcOption.Flags.media_only)) == 0)
|
||||
.OrderBy(dco => dco.flags);
|
||||
var flags = _dcSession.DataCenter.flags;
|
||||
var altOptions = _session.DcOptions.Where(dc => dc.id == _dcSession.DataCenter.id && dc.flags != flags
|
||||
&& (dc.flags & DcOption.Flags.media_only) <= (flags & DcOption.Flags.media_only)
|
||||
&& (dc.flags & (DcOption.Flags.cdn | DcOption.Flags.tcpo_only)) == 0)
|
||||
.OrderBy(dc => (dc.flags ^ flags) & DcOption.Flags.media_only).ThenBy(dc => dc.flags ^ flags);
|
||||
// try alternate addresses for this DC
|
||||
foreach (var dcOption in altOptions)
|
||||
{
|
||||
|
|
@ -884,7 +887,11 @@ namespace WTelegram
|
|||
try
|
||||
{
|
||||
tcpClient = await TcpHandler(endpoint.Address.ToString(), endpoint.Port);
|
||||
_dcSession.DataCenter = dcOption;
|
||||
if (((dcOption.flags ^ flags) & DcOption.Flags.media_only) == 0) // test to prevent AltDC becoming MainDC
|
||||
_dcSession.DataCenter = dcOption;
|
||||
else
|
||||
_dcSession.DataCenter = new DcOption { flags = dcOption.flags ^ DcOption.Flags.media_only,
|
||||
id = dcOption.id, ip_address = dcOption.ip_address, port = dcOption.port, secret = dcOption.secret };
|
||||
break;
|
||||
}
|
||||
catch (SocketException) { }
|
||||
|
|
|
|||
Loading…
Reference in a new issue