diff --git a/Examples/Program_ListenUpdates.cs b/Examples/Program_ListenUpdates.cs index 0bf7f4a..1233764 100644 --- a/Examples/Program_ListenUpdates.cs +++ b/Examples/Program_ListenUpdates.cs @@ -25,8 +25,10 @@ namespace WTelegramClientTest // We collect all infos about the users/chats so that updates can be printed with their names var dialogs = await Client.Messages_GetAllDialogs(); // dialogs = groups/channels/users dialogs.CollectUsersChats(Manager.Users, Manager.Chats); + Console.ReadKey(); - } + } // WTelegram.Client gets disposed when exiting this scope + //Manager.SaveState("Updates.state"); // if you want to resume missed updates on the next run (see WithUpdateManager above) } diff --git a/generator/MTProtoGenerator.cs b/generator/MTProtoGenerator.cs index e0025e3..14db231 100644 --- a/generator/MTProtoGenerator.cs +++ b/generator/MTProtoGenerator.cs @@ -85,7 +85,7 @@ public class MTProtoGenerator : IIncrementalGenerator continue; } if (id == 0x3072CFA1) // GzipPacked - makeTL.AppendLine($"\t\t\t0x{id:X8} => reader.ReadTLGzipped(),"); + makeTL.AppendLine($"\t\t\t0x{id:X8} => (IObject)reader.ReadTLGzipped(typeof(IObject)),"); else if (name != "Null" && (ns != "TL.Methods" || name == "Ping")) makeTL.AppendLine($"\t\t\t0x{id:X8} => new {(ns == "TL" ? "" : ns + '.')}{name}().ReadTL(reader),"); var override_ = symbol.BaseType == object_ ? "" : "override "; diff --git a/src/Client.cs b/src/Client.cs index 8cf1339..39c9c7b 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -570,7 +570,7 @@ namespace WTelegram if (peek == Layer.RpcErrorCtor) result = reader.ReadTLObject(Layer.RpcErrorCtor); else if (peek == Layer.GZipedCtor) - result = reader.ReadTLGzipped(); + result = reader.ReadTLGzipped(rpc.type); else { reader.BaseStream.Position -= 4; diff --git a/src/TL.cs b/src/TL.cs index 0045cef..6d620ed 100644 --- a/src/TL.cs +++ b/src/TL.cs @@ -350,10 +350,10 @@ namespace TL writer.Write(0); // null arrays/strings are serialized as empty } - internal static IObject ReadTLGzipped(this BinaryReader reader) + internal static object ReadTLGzipped(this BinaryReader reader, Type type) { using var gzipReader = new BinaryReader(new GZipStream(new MemoryStream(reader.ReadTLBytes()), CompressionMode.Decompress)); - return ReadTLObject(gzipReader); + return gzipReader.ReadTLValue(type); } internal static bool ReadTLBool(this BinaryReader reader) => reader.ReadUInt32() switch