mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
resolved PR comments
This commit is contained in:
parent
f258b6ede8
commit
2d540787e7
|
|
@ -139,7 +139,7 @@ Full code you can see at [DownloadFileFromContactTest](https://github.com/sochix
|
||||||
|
|
||||||
# Events Sample code
|
# Events Sample code
|
||||||
```csharp
|
```csharp
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using TeleSharp.TL;
|
using TeleSharp.TL;
|
||||||
using TLSharp.Core;
|
using TLSharp.Core;
|
||||||
|
|
@ -234,7 +234,7 @@ namespace TLSharpPOC
|
||||||
var msg = await client.GetHistoryAsync(peer, 0, 0, 0);
|
var msg = await client.GetHistoryAsync(peer, 0, 0, 0);
|
||||||
Console.WriteLine(msg);
|
Console.WriteLine(msg);
|
||||||
if (msg is TLMessages messages)
|
if (msg is TLMessages messages)
|
||||||
{
|
{
|
||||||
foreach (var message in messages.Messages)
|
foreach (var message in messages.Messages)
|
||||||
{
|
{
|
||||||
if (message is TLMessage m1)
|
if (message is TLMessage m1)
|
||||||
|
|
@ -247,7 +247,7 @@ namespace TLSharpPOC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (msg is TLMessagesSlice messagesSlice)
|
else if (msg is TLMessagesSlice messagesSlice)
|
||||||
{
|
{
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
@ -273,7 +273,7 @@ namespace TLSharpPOC
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Wait in a loop to handle incoming updates. No need to poll.
|
// -- Wait in a loop to handle incoming updates. No need to poll.
|
||||||
for (; ; )
|
while(true)
|
||||||
{
|
{
|
||||||
await client.WaitEventAsync(TimeSpan.FromSeconds(1));
|
await client.WaitEventAsync(TimeSpan.FromSeconds(1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -269,19 +269,12 @@ namespace TLSharp.Core.Network
|
||||||
|
|
||||||
private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, TLMethod request)
|
private bool HandleUpdate(uint code, int sequence, BinaryReader messageReader, TLMethod request)
|
||||||
{
|
{
|
||||||
try
|
var update = ParseUpdate(code, messageReader);
|
||||||
|
if (update != null && UpdatesEvent != null)
|
||||||
{
|
{
|
||||||
var update = ParseUpdate(code, messageReader);
|
UpdatesEvent(update);
|
||||||
if (update != null && UpdatesEvent != null)
|
|
||||||
{
|
|
||||||
UpdatesEvent(update);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader)
|
private TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader)
|
||||||
|
|
|
||||||
|
|
@ -382,6 +382,7 @@ namespace TLSharp.Tests
|
||||||
{
|
{
|
||||||
IList<TLMessage> newMsgs = new List<TLMessage>();
|
IList<TLMessage> newMsgs = new List<TLMessage>();
|
||||||
TLUser user = null;
|
TLUser user = null;
|
||||||
|
var updateMsg = "Send yourself an UPDATE_1 message to trigger update during loop";
|
||||||
|
|
||||||
var client = NewClient();
|
var client = NewClient();
|
||||||
await client.ConnectAsync();
|
await client.ConnectAsync();
|
||||||
|
|
@ -435,8 +436,8 @@ namespace TLSharp.Tests
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Console.WriteLine("Send yourself an UPDATE_1 message to trigger update during loop");
|
Console.WriteLine(updateMsg);
|
||||||
Debug.WriteLine("Send yourself an UPDATE_1 message to trigger update during loop");
|
Debug.WriteLine(updateMsg);
|
||||||
|
|
||||||
await client.MainLoopAsync(new TimeSpan(0, 0, 1));
|
await client.MainLoopAsync(new TimeSpan(0, 0, 1));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue