TLSharp/TLSharp.Core/Requests/AuthSendCodeRequest.cs

55 lines
1.7 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 AuthSendCodeRequest : MTProtoRequest
{
private readonly string _phoneNumber;
private readonly int _smsType;
private readonly int _apiId;
private readonly string _apiHash;
private readonly string _langCode;
public bool _phoneRegistered;
public string _phoneCodeHash;
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public AuthSendCodeRequest(string phoneNumber, int smsType, int apiId, string apiHash, string langCode)
{
_phoneNumber = phoneNumber;
_smsType = smsType;
_apiId = apiId;
_apiHash = apiHash;
_langCode = langCode;
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override void OnSend(BinaryWriter writer)
{
writer.Write(0x768d5f4d);
Serializers.String.write(writer, _phoneNumber);
writer.Write(_smsType);
writer.Write(_apiId);
Serializers.String.write(writer, _apiHash);
Serializers.String.write(writer, _langCode);
}
2015-09-28 04:01:17 +02:00
2016-04-18 12:50:57 +02:00
public override void OnResponse(BinaryReader reader)
{
var boolTrue = 0x997275b5;
var dataCode = reader.ReadUInt32(); // 0x2215bcbd
_phoneRegistered = reader.ReadUInt32() == boolTrue;
_phoneCodeHash = Serializers.String.read(reader);
var sendCodeTimeout = reader.ReadInt32();
var isPassword = reader.ReadUInt32() == boolTrue;
}
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
}