resolved PR comments

This commit is contained in:
mark 2020-05-12 23:30:12 +01:00
parent f258b6ede8
commit 2d540787e7
3 changed files with 11 additions and 17 deletions

View file

@ -139,7 +139,7 @@ Full code you can see at [DownloadFileFromContactTest](https://github.com/sochix
# Events Sample code
```csharp
using System;
using System;
using System.Threading.Tasks;
using TeleSharp.TL;
using TLSharp.Core;
@ -234,7 +234,7 @@ namespace TLSharpPOC
var msg = await client.GetHistoryAsync(peer, 0, 0, 0);
Console.WriteLine(msg);
if (msg is TLMessages messages)
{
{
foreach (var message in messages.Messages)
{
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;
int total = 0;
@ -273,7 +273,7 @@ namespace TLSharpPOC
}
// -- Wait in a loop to handle incoming updates. No need to poll.
for (; ; )
while(true)
{
await client.WaitEventAsync(TimeSpan.FromSeconds(1));
}

View file

@ -269,19 +269,12 @@ namespace TLSharp.Core.Network
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);
if (update != null && UpdatesEvent != null)
{
UpdatesEvent(update);
}
return true;
}
catch (Exception e)
{
return false;
UpdatesEvent(update);
}
return true;
}
private TLAbsUpdates ParseUpdate(uint code, BinaryReader messageReader)

View file

@ -382,6 +382,7 @@ namespace TLSharp.Tests
{
IList<TLMessage> newMsgs = new List<TLMessage>();
TLUser user = null;
var updateMsg = "Send yourself an UPDATE_1 message to trigger update during loop";
var client = NewClient();
await client.ConnectAsync();
@ -435,8 +436,8 @@ namespace TLSharp.Tests
}
};
Console.WriteLine("Send yourself an UPDATE_1 message to trigger update during loop");
Debug.WriteLine("Send yourself an UPDATE_1 message to trigger update during loop");
Console.WriteLine(updateMsg);
Debug.WriteLine(updateMsg);
await client.MainLoopAsync(new TimeSpan(0, 0, 1));