TLSharp/TLSharp.Core/Requests/AuthSignInRequest.cs

46 lines
1.3 KiB
C#
Raw Normal View History

2015-09-28 04:01:17 +02:00
using System;
using System.IO;
using TLSharp.Core.MTProto;
namespace TLSharp.Core.Requests
{
2016-04-18 12:50:57 +02:00
public class AuthSignInRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly string _phoneCodeHash;
private readonly string _code;
public User user;
public int SessionExpires;
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public AuthSignInRequest(string phoneNumber, string phoneCodeHash, string code)
{
_phoneNumber = phoneNumber;
_phoneCodeHash = phoneCodeHash;
_code = code;
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override void OnSend(BinaryWriter writer)
{
writer.Write(0xbcd51581);
Serializers.String.write(writer, _phoneNumber);
Serializers.String.write(writer, _phoneCodeHash);
Serializers.String.write(writer, _code);
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override void OnResponse(BinaryReader reader)
{
var dataCode = reader.ReadUInt32(); //0xf6b673a4
var expires = reader.ReadInt32();
user = TL.Parse<User>(reader);
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override void OnException(Exception exception)
{
throw new NotImplementedException();
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override bool Confirmed => true;
public override bool Responded { get; }
}
2015-09-28 04:01:17 +02:00
}