raise event for Pong and Affected*

This commit is contained in:
Wizou 2024-03-23 17:51:00 +01:00
parent 39760f9306
commit 3304ba4bac
3 changed files with 17 additions and 3 deletions

View file

@ -578,8 +578,11 @@ namespace WTelegram
else
{
Helpers.Log(1, $" → {result?.GetType().Name,-37} #{(short)msgId.GetHashCode():X4}");
if (OnOwnUpdate != null && result is UpdatesBase updates)
RaiseOwnUpdate(updates);
if (OnOwnUpdate != null)
if (result is UpdatesBase updates)
RaiseOwnUpdate(updates);
else if (result is Messages_AffectedMessages affected)
RaiseOwnUpdate(new UpdateShort { update = new UpdateAffectedMessages { affected = affected }, date = MsgIdToStamp(_lastRecvMsgId) });
}
rpc.tcs.SetResult(result);
@ -665,6 +668,7 @@ namespace WTelegram
break;
case Pong pong:
SetResult(pong.msg_id, pong);
RaiseUpdate(pong);
break;
case FutureSalts futureSalts:
SetResult(futureSalts.req_msg_id, futureSalts);
@ -724,7 +728,7 @@ namespace WTelegram
rpc.tcs.SetException(new WTException($"BadMsgNotification {badMsgNotification.error_code}"));
}
else
RaiseUpdate(obj);
RaiseUpdate(badMsgNotification);
break;
default:
RaiseUpdate(obj);

View file

@ -577,6 +577,7 @@ namespace TL
public abstract Update[] OtherUpdates { get; }
public abstract bool Final { get; }
public abstract int Timeout { get; }
public abstract int Pts { get; }
}
partial class Updates_ChannelDifferenceEmpty
{
@ -584,6 +585,7 @@ namespace TL
public override Update[] OtherUpdates => [];
public override bool Final => flags.HasFlag(Flags.final);
public override int Timeout => timeout;
public override int Pts => pts;
}
partial class Updates_ChannelDifference
{
@ -591,6 +593,7 @@ namespace TL
public override Update[] OtherUpdates => other_updates;
public override bool Final => flags.HasFlag(Flags.final);
public override int Timeout => timeout;
public override int Pts => pts;
}
partial class Updates_ChannelDifferenceTooLong
{
@ -598,6 +601,7 @@ namespace TL
public override Update[] OtherUpdates => null;
public override bool Final => flags.HasFlag(Flags.final);
public override int Timeout => timeout;
public override int Pts => dialog is Dialog d ? d.pts : 0;
}
partial class ChannelParticipantBase

View file

@ -352,6 +352,12 @@ namespace TL
public static implicit operator byte[](Int256 int256) => int256.raw;
}
public class UpdateAffectedMessages : Update // auto-generated for OnOwnUpdate in case of such API call result
{
public Messages_AffectedMessages affected;
public override (long, int, int) GetMBox() => (0, affected.pts, affected.pts_count);
}
// Below TL types are commented "parsed manually" from https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/Resources/tl/mtproto.tl
[TLDef(0x7A19CB76)] //RSA_public_key#7a19cb76 n:bytes e:bytes = RSAPublicKey