mirror of
https://github.com/sochix/TLSharp.git
synced 2025-12-06 08:02:00 +01:00
* Added logging messages.
* Implemented ping.
This commit is contained in:
parent
2c8ea9c7ec
commit
b71a72343c
|
|
@ -199,6 +199,7 @@ namespace TLSharp.Core.Network
|
|||
|
||||
uint code = messageReader.ReadUInt32();
|
||||
messageReader.BaseStream.Position -= 4;
|
||||
logger.Info("Processing message {0:x8}", code);
|
||||
switch (code)
|
||||
{
|
||||
case 0x73f1f8dc: // container
|
||||
|
|
@ -243,7 +244,7 @@ namespace TLSharp.Core.Network
|
|||
case 0x11f1331c:
|
||||
return HandleUpdate(code, sequence, messageReader, request);
|
||||
default:
|
||||
Console.WriteLine ("Msg code: {0:x8}", code);
|
||||
logger.Info("unhandled message");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ namespace TLSharp.Core
|
|||
public async Task MainLoopAsync(int timeslicems)
|
||||
{
|
||||
logger.Trace("Entered loop");
|
||||
await SendPingAsync();
|
||||
var lastPing = DateTime.UtcNow;
|
||||
for (;;)
|
||||
{
|
||||
try
|
||||
|
|
@ -131,6 +133,12 @@ namespace TLSharp.Core
|
|||
}
|
||||
finally
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if ((now - lastPing).TotalSeconds >= 30)
|
||||
{
|
||||
await SendPingAsync();
|
||||
lastPing = now;
|
||||
}
|
||||
if (IdleLoop != null)
|
||||
{
|
||||
logger.Trace("Running idle tasks");
|
||||
|
|
@ -262,6 +270,7 @@ namespace TLSharp.Core
|
|||
}
|
||||
public async Task<T> SendRequestAsync<T>(TLMethod methodToExecute)
|
||||
{
|
||||
logger.Info("Sending Request: {0} {1:x8}", methodToExecute, methodToExecute.Constructor);
|
||||
await RequestWithDcMigration(methodToExecute);
|
||||
|
||||
var result = methodToExecute.GetType().GetProperty("Response").GetValue(methodToExecute);
|
||||
|
|
|
|||
Loading…
Reference in a new issue