public override byte[] ToBytes()
        {
            byte[] signature;

            if (Constants.SupportedLayer == 41)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(41)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 40)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(40)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 39)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(39)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 38)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(38)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 37)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(37)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 36)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(36)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 35)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(35)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 34)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(34)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 33)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(33)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 32)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(32)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 31)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(31)
                }.ToBytes();
            }


            if (Constants.SupportedLayer == 30)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(30)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 29)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(29)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 28)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(28)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 27)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(27)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 26)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(26)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 25)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(25)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 24)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(24)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 23)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(23)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 22)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(22)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 21)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(21)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 20)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(20)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 19)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(19)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 18)
            {
                signature = TLUtils.SignatureToBytes(Signature18);
            }

            if (Constants.SupportedLayer == 17)
            {
                signature = TLUtils.SignatureToBytes(Signature17);
            }

            if (Constants.SupportedLayer == 16)
            {
                signature = TLUtils.SignatureToBytes(Signature16);
            }

            if (Constants.SupportedLayer == 15)
            {
                signature = TLUtils.SignatureToBytes(Signature15);
            }

            if (Constants.SupportedLayer == 14)
            {
                signature = TLUtils.SignatureToBytes(Signature14);
            }

            if (Constants.SupportedLayer == 13)
            {
                signature = TLUtils.SignatureToBytes(Signature13);
            }

            if (Constants.SupportedLayer == 12)
            {
                signature = TLUtils.SignatureToBytes(Signature12);
            }

            if (Constants.SupportedLayer == 11)
            {
                signature = TLUtils.SignatureToBytes(Signature11);
            }

            if (Constants.SupportedLayer == 1)
            {
                signature = new byte[] {};
            }
            if (Constants.SupportedLayer == 2)
            {
                signature = TLUtils.SignatureToBytes(Signature2);
            }
            if (Constants.SupportedLayer == 3)
            {
                signature = TLUtils.SignatureToBytes(Signature3);
            }
            if (Constants.SupportedLayer == 4)
            {
                signature = TLUtils.SignatureToBytes(Signature4);
            }
            if (Constants.SupportedLayer == 5)
            {
                signature = TLUtils.SignatureToBytes(Signature5);
            }
            if (Constants.SupportedLayer == 6)
            {
                signature = TLUtils.SignatureToBytes(Signature6);
            }
            if (Constants.SupportedLayer == 7)
            {
                signature = TLUtils.SignatureToBytes(Signature7);
            }
            if (Constants.SupportedLayer == 8)
            {
                signature = TLUtils.SignatureToBytes(Signature8);
            }
            if (Constants.SupportedLayer == 9)
            {
                signature = TLUtils.SignatureToBytes(Signature9);
            }
            if (Constants.SupportedLayer == 10)
            {
                signature = TLUtils.SignatureToBytes(Signature10);
            }



            return(TLUtils.Combine(signature, Data.ToBytes()));
        }
示例#2
0
        public void SendInformativeMessageInternal <T>(string caption, TLObject obj, Action <T> callback, Action <TLRPCError> faultCallback = null,
                                                       int?maxAttempt             = null, // to send delayed items
                                                       Action <int> attemptFailed = null,
                                                       Action fastCallback        = null) // to send delayed items
        {
            if (_activeTransport.AuthKey == null)
            {
                var delayedItem = new DelayedItem
                {
                    SendTime = DateTime.Now,
                    //SendBeforeTime = sendBeforeTime,
                    Caption       = caption,
                    Object        = obj,
                    Callback      = t => callback((T)t),
                    AttemptFailed = attemptFailed,
                    FaultCallback = faultCallback,
                    MaxAttempt    = maxAttempt
                };
                lock (_delayedItemsRoot)
                {
                    _delayedItems.Add(delayedItem);
                }
#if LOG_REGISTRATION
                TLUtils.WriteLog(string.Format("Add delayed item {0} sendTime={1}", delayedItem.Caption, delayedItem.SendTime.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)));
#endif

                return;
            }

            lock (_activeTransportRoot)
            {
                if (_activeTransport.Closed)
                {
                    var  transportDCId             = _activeTransport.DCId;
                    var  transportKey              = _activeTransport.AuthKey;
                    var  transportSalt             = _activeTransport.Salt;
                    var  transportSessionId        = _activeTransport.SessionId;
                    var  transportSequenceNumber   = _activeTransport.SequenceNumber;
                    var  transportClientTicksDelta = _activeTransport.ClientTicksDelta;
                    bool isCreated;
                    _activeTransport = _transportService.GetTransport(_activeTransport.Host, _activeTransport.Port, Type, out isCreated);
                    if (isCreated)
                    {
                        _activeTransport.DCId             = transportDCId;
                        _activeTransport.AuthKey          = transportKey;
                        _activeTransport.Salt             = transportSalt;
                        _activeTransport.SessionId        = transportSessionId; //TLLong.Random();
                        _activeTransport.SequenceNumber   = transportSequenceNumber;
                        _activeTransport.ClientTicksDelta = transportClientTicksDelta;
                        _activeTransport.PacketReceived  += OnPacketReceived;
                    }
                }
            }

            PrintCaption(caption);

            TLObject data;
            lock (_activeTransportRoot)
            {
                if (!_activeTransport.Initiated || caption == "auth.sendCode")
                {
                    //var cultureinfo = CultureInfo.InvariantCulture
                    //SystemEvents.TimeChanged
                    var initConnection = new TLInitConnection
                    {
                        ApiId         = Constants.ApiId,
                        AppVersion    = _deviceInfo.AppVersion,
                        Query         = obj,
                        DeviceModel   = _deviceInfo.DeviceModel,
                        LangCode      = Utils.CurrentUICulture(),
                        SystemVersion = _deviceInfo.SystemVersion
                    };

                    SaveInitConnectionAsync(initConnection);

                    // TODO?
                    var withLayerN = new TLInvokeWithLayer {
                        Query = initConnection, Layer = Constants.SupportedLayer
                    };
                    data = withLayerN;
                    _activeTransport.Initiated = true;
                }
                else
                {
                    data = obj;
                }
            }

            int  sequenceNumber;
            long?messageId;
            lock (_activeTransportRoot)
            {
                sequenceNumber = _activeTransport.SequenceNumber * 2 + 1;
                _activeTransport.SequenceNumber++;
                messageId = _activeTransport.GenerateMessageId(true);
            }
            var authKey           = _activeTransport.AuthKey;
            var salt              = _activeTransport.Salt;
            var sessionId         = _activeTransport.SessionId;
            var clientsTicksDelta = _activeTransport.ClientTicksDelta;
            var transportMessage  = CreateTLTransportMessage(salt ?? 0, sessionId ?? 0, sequenceNumber, messageId ?? 0, data);
            var encryptedMessage  = CreateTLEncryptedMessage(authKey, transportMessage);

            //save items to history
            var historyItem = new HistoryItem
            {
                SendTime = DateTime.Now,
                //SendBeforeTime = sendBeforeTime,
                Caption          = caption,
                Object           = obj,
                Message          = transportMessage,
                Callback         = t => callback?.Invoke((T)t),
                AttemptFailed    = attemptFailed,
                FaultCallback    = faultCallback,
                ClientTicksDelta = clientsTicksDelta,
                Status           = RequestStatus.Sent,
            };

            lock (_historyRoot)
            {
#if DEBUG
                HistoryItem existingItem;
                if (_history.TryGetValue(historyItem.Hash, out existingItem))
                {
                    Execute.ShowDebugMessage(string.Format("Duplicated history item hash={0} existing={1} new={2}", historyItem.Hash, existingItem.Caption, historyItem.Caption));
                }
                _history[historyItem.Hash] = historyItem;
#else
                _history[historyItem.Hash] = historyItem;
#endif
            }

#if DEBUG
            ITransport transport;
            lock (_activeTransportRoot)
            {
                transport = _activeTransport;
            }
            var    transportId     = transport.Id;
            var    lastReceiveTime = transport.LastReceiveTime;
            int    historyCount;
            string historyDescription;
            lock (_historyRoot)
            {
                historyCount       = _history.Count;
                historyDescription = string.Join("\n", _history.Values.Select(x => x.Caption + " " + x.Hash));
            }
            var currentPacketLength = transport.PacketLength;
            var lastPacketLength    = transport.LastPacketLength;

            RaiseTransportChecked(new TransportCheckedEventArgs
            {
                TransportId        = transportId,
                SessionId          = sessionId,
                AuthKey            = authKey,
                LastReceiveTime    = lastReceiveTime,
                HistoryCount       = historyCount,
                HistoryDescription = historyDescription,
                NextPacketLength   = currentPacketLength,
                LastPacketLength   = lastPacketLength
            });
#endif

#if LOG_REGISTRATION
            TLUtils.WriteLog(string.Format("Add history item {0} sendTime={1}", historyItem.Caption, historyItem.SendTime.ToString("yyyy-MM-dd HH:mm:ss.fff", CultureInfo.InvariantCulture)));
#endif
#if DEBUG
            if (historyItem.Caption != "account.updateStatus")     // to avoid deadlock on deactivation
            {
                RaisePropertyChanged(() => History);
            }
#endif

            //Debug.WriteLine(">>{0, -30} MsgId {1} SeqNo {2, -4} SessionId {3} ClientTicksDelta {4}", caption, transportMessage.MessageId.Value, transportMessage.SeqNo.Value, transportMessage.SessionId.Value, clientsTicksDelta);

            var captionString = string.Format("{0} {1} {2}", caption, transportMessage.SessionId, transportMessage.MsgId);
            SendPacketAsync(_activeTransport, captionString, encryptedMessage,
                            result =>
            {
                if (!result)
                {
                    if (historyItem != null)
                    {
                        lock (_historyRoot)
                        {
                            _history.Remove(historyItem.Hash);
                        }
#if DEBUG
                        if (historyItem.Caption != "account.updateStatus")     // to avoid deadlock on deactivation
                        {
                            RaisePropertyChanged(() => History);
                        }
#endif
                    }
                    faultCallback?.Invoke(new TLRPCError {
                        ErrorCode = 404, ErrorMessage = "FastCallback SocketError=" + result
                    });
                }
            },
                            error =>
            {
                if (historyItem != null)
                {
                    lock (_historyRoot)
                    {
                        _history.Remove(historyItem.Hash);
                    }
#if DEBUG
                    if (historyItem.Caption != "account.updateStatus")     // to avoid deadlock on deactivation
                    {
                        RaisePropertyChanged(() => History);
                    }
#endif
                }
                faultCallback?.Invoke(new TLRPCError
                {
                    ErrorCode = 404,
#if WINDOWS_PHONE
                    SocketError = error.Error,
#endif
                    // TODO: Exception = error.Exception
                });
            });
        }
示例#3
0
        public override byte[] ToBytes()
        {
            byte[] signature;

            if (Constants.SupportedLayer == 85)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 84)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 83)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 82)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 81)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 80)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 79)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 78)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 76)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 75)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 74)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 73)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 72)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 71)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 70)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 69)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 68)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 67)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 66)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 65)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 64)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 63)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 62)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 61)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 60)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 59)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 58)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 57)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 56)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 55)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 54)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 53)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 52)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 51)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 50)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 49)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 48)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 47)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 46)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 45)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 44)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 43)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(Constants.SupportedLayer)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 42)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(42)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 41)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(41)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 40)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(40)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 39)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(39)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 38)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(38)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 37)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(37)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 36)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(36)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 35)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(35)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 34)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(34)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 33)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(33)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 32)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(32)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 31)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(31)
                }.ToBytes();
            }


            if (Constants.SupportedLayer == 30)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(30)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 29)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(29)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 28)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(28)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 27)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(27)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 26)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(26)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 25)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(25)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 24)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(24)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 23)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(23)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 22)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(22)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 21)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(21)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 20)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(20)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 19)
            {
                signature = new TLInvokeWithLayer {
                    Layer = new TLInt(19)
                }.ToBytes();
            }

            if (Constants.SupportedLayer == 18)
            {
                signature = TLUtils.SignatureToBytes(Signature18);
            }

            if (Constants.SupportedLayer == 17)
            {
                signature = TLUtils.SignatureToBytes(Signature17);
            }

            if (Constants.SupportedLayer == 16)
            {
                signature = TLUtils.SignatureToBytes(Signature16);
            }

            if (Constants.SupportedLayer == 15)
            {
                signature = TLUtils.SignatureToBytes(Signature15);
            }

            if (Constants.SupportedLayer == 14)
            {
                signature = TLUtils.SignatureToBytes(Signature14);
            }

            if (Constants.SupportedLayer == 13)
            {
                signature = TLUtils.SignatureToBytes(Signature13);
            }

            if (Constants.SupportedLayer == 12)
            {
                signature = TLUtils.SignatureToBytes(Signature12);
            }

            if (Constants.SupportedLayer == 11)
            {
                signature = TLUtils.SignatureToBytes(Signature11);
            }

            if (Constants.SupportedLayer == 1)
            {
                signature = new byte[] { };
            }
            if (Constants.SupportedLayer == 2)
            {
                signature = TLUtils.SignatureToBytes(Signature2);
            }
            if (Constants.SupportedLayer == 3)
            {
                signature = TLUtils.SignatureToBytes(Signature3);
            }
            if (Constants.SupportedLayer == 4)
            {
                signature = TLUtils.SignatureToBytes(Signature4);
            }
            if (Constants.SupportedLayer == 5)
            {
                signature = TLUtils.SignatureToBytes(Signature5);
            }
            if (Constants.SupportedLayer == 6)
            {
                signature = TLUtils.SignatureToBytes(Signature6);
            }
            if (Constants.SupportedLayer == 7)
            {
                signature = TLUtils.SignatureToBytes(Signature7);
            }
            if (Constants.SupportedLayer == 8)
            {
                signature = TLUtils.SignatureToBytes(Signature8);
            }
            if (Constants.SupportedLayer == 9)
            {
                signature = TLUtils.SignatureToBytes(Signature9);
            }
            if (Constants.SupportedLayer == 10)
            {
                signature = TLUtils.SignatureToBytes(Signature10);
            }



            return(TLUtils.Combine(signature, Data.ToBytes()));
        }