Пример #1
0
 public override void deserializeBody(/*InputStream*/BufferedStream stream, TLContext context)
 {
     try {
         packedData = StreamingUtils.readTLBytes(stream);
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #2
0
 public override void deserializeBody(BufferedStream stream, TLContext context)
 {
     try {
         this.expires = StreamingUtils.readInt(stream);
         this.user = ((TLAbsUser)StreamingUtils.readTLObject(stream, context));
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #3
0
 override public void deserializeBody(BufferedStream stream, TLContext context) {
     try {
         session = StreamingUtils.readBytes(8, stream);
     }
     catch (IOException e)
     {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #4
0
          override public void deserializeBody(BufferedStream stream, TLContext context)

          {
            this.id = StreamingUtils.readInt(stream);
            StreamingUtils.readTLString(stream);
            StreamingUtils.readTLString(stream);
            StreamingUtils.readTLString(stream);
            StreamingUtils.readTLObject(stream, context);
            StreamingUtils.readTLObject(stream, context);
            StreamingUtils.readTLBool(stream);
          }
Пример #5
0
 public override void deserializeBody(BufferedStream stream, TLContext context)
 {
     try {
         this.phoneRegistered = StreamingUtils.readTLBool(stream);
         this.phoneCodeHash = StreamingUtils.readTLString(stream);
         this.sendCallTimeout = StreamingUtils.readInt(stream);
         this.isPassword = StreamingUtils.readTLBool(stream);
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #6
0
 public override void deserializeBody(BufferedStream stream, TLContext context)
 {
     try {
         this.date = StreamingUtils.readInt(stream);
         this.testMode = StreamingUtils.readTLBool(stream);
         this.thisDc = StreamingUtils.readInt(stream);
         this.dcOptions = (TLVector<TLDcOption>)StreamingUtils.readTLVector(stream, context);
         this.chatSizeMax = StreamingUtils.readInt(stream);
         this.broadcastSizeMax = StreamingUtils.readInt(stream);
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #7
0
 public override void deserializeBody(BufferedStream stream, TLContext context)
 {
     try {
         keys = (TLVector<TLKey>)StreamingUtils.readTLVector(stream, context);
         dcInfos = (TLVector<TLDcInfo>)StreamingUtils.readTLVector(stream, context);
         primaryDc = StreamingUtils.readInt(stream);
         isbAuthorized = StreamingUtils.readTLBool(stream);
         uid = StreamingUtils.readInt(stream);
         phone = StreamingUtils.readTLString(stream);
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #8
0
 public override void deserializeBody(BufferedStream stream, TLContext context)
 {
     try {
         dcId = StreamingUtils.readInt(stream);
         authKey = StreamingUtils.readBytes(256, stream);
         isbAuthorised = StreamingUtils.readTLBool(stream);
         salts = (TLVector<TLLastKnownSalt>)StreamingUtils.readTLVector(stream, context);
         oldSessions = (TLVector<TLOldSession>)StreamingUtils.readTLVector(stream, context);
     }
     catch (IOException e)
     {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
     }
 }
Пример #9
0
        public virtual ServerDhParams deserializeResponse(InputStream stream, TLContext context)
        {
            TLObject obj2 = context.deserializeMessage(stream);

            if (obj2 == null)
            {
                Throwable.__ <suppressFillInStackTrace>();
                throw new DeserializeException("Unable to deserialize response");
            }
            if (obj2 is ServerDhParams)
            {
                return((ServerDhParams)obj2);
            }
            Throwable.__ <suppressFillInStackTrace>();
            throw new DeserializeException("Response has incorrect type");
        }
Пример #10
0
        public virtual TLInviteText deserializeResponse(InputStream stream, TLContext context)
        {
            TLObject obj2 = StreamingUtils.readTLObject(stream, context);

            if (obj2 == null)
            {
                Throwable.__ <suppressFillInStackTrace>();
                throw new IOException("Unable to parse response");
            }
            if (obj2 is TLInviteText)
            {
                return((TLInviteText)obj2);
            }
            Throwable.__ <suppressFillInStackTrace>();
            throw new IOException(new StringBuilder().append("Incorrect response type. Expected org.telegram.api.help.TLInviteText, got: ").append(Object.instancehelper_getClass(obj2).getCanonicalName()).toString());
        }
Пример #11
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags        = StreamingUtils.readInt(stream);
     this.queryId      = StreamingUtils.readLong(stream);
     this.userId       = StreamingUtils.readInt(stream);
     this.msgId        = StreamingUtils.readTLObject(stream, context);
     this.chatInstance = StreamingUtils.readInt(stream);
     if ((this.flags & 1) != 0)
     {
         this.data = StreamingUtils.readTLBytes(stream, context);
     }
     if ((this.flags & 2) != 0)
     {
         this.gameShortName = StreamingUtils.readTLString(stream);
     }
 }
Пример #12
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags    = StreamingUtils.readInt(stream);
     this.id       = StreamingUtils.readInt(stream);
     this.pts      = StreamingUtils.readInt(stream);
     this.ptsCount = StreamingUtils.readInt(stream);
     this.date     = StreamingUtils.readInt(stream);
     if ((this.flags & 0x200) != 0)
     {
         this.media = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x80) != 0)
     {
         this.entities = StreamingUtils.readTLVector(stream, context);
     }
 }
Пример #13
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags    = StreamingUtils.readInt(stream);
     this.duration = StreamingUtils.readInt(stream);
     if ((this.flags & 1) != 0)
     {
         this.title = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 2) != 0)
     {
         this.performer = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 4) != 0)
     {
         this.waveform = StreamingUtils.readTLBytes(stream, context);
     }
 }
Пример #14
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     base.deserializeBody(stream, context);
     this.hash          = StreamingUtils.readLong(stream);
     this.flags         = StreamingUtils.readInt(stream);
     this.deviceModel   = StreamingUtils.readTLString(stream);
     this.platform      = StreamingUtils.readTLString(stream);
     this.systemVersion = StreamingUtils.readTLString(stream);
     this.apiId         = StreamingUtils.readInt(stream);
     this.appName       = StreamingUtils.readTLString(stream);
     this.appVersion    = StreamingUtils.readTLString(stream);
     this.dateCreated   = StreamingUtils.readInt(stream);
     this.dateActive    = StreamingUtils.readInt(stream);
     this.ip            = StreamingUtils.readTLString(stream);
     this.country       = StreamingUtils.readTLString(stream);
     this.region        = StreamingUtils.readTLString(stream);
 }
Пример #15
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     if ((this.flags & 1) != 0)
     {
         this.fromId = StreamingUtils.readInt(stream);
     }
     this.date = StreamingUtils.readInt(stream);
     if ((this.flags & 2) != 0)
     {
         this.channelId = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 4) != 0)
     {
         this.channelPost = StreamingUtils.readInt(stream);
     }
 }
Пример #16
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags           = StreamingUtils.readInt(stream);
     this.peer            = StreamingUtils.readTLObject(stream, context);
     this.topMessage      = StreamingUtils.readInt(stream);
     this.readInboxMaxId  = StreamingUtils.readInt(stream);
     this.readOutboxMaxId = StreamingUtils.readInt(stream);
     this.unreadCount     = StreamingUtils.readInt(stream);
     this.notifySettings  = StreamingUtils.readTLObject(stream, context);
     if ((this.flags & 1) != 0)
     {
         this.pts = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 2) != 0)
     {
         this.draft = StreamingUtils.readTLObject(stream, context);
     }
 }
Пример #17
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     this.id    = StreamingUtils.readInt(stream);
     if ((this.flags & 0x100) != 0)
     {
         this.fromId = StreamingUtils.readInt(stream);
     }
     this.toId = StreamingUtils.readTLObject(stream, context);
     if ((this.flags & 4) != 0)
     {
         this.fwdFrom = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x800) != 0)
     {
         this.viaBotId = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 8) != 0)
     {
         this.replyToMsgId = StreamingUtils.readInt(stream);
     }
     this.date    = StreamingUtils.readInt(stream);
     this.message = StreamingUtils.readTLString(stream);
     if ((this.flags & 0x200) != 0)
     {
         this.media = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x40) != 0)
     {
         this.replyMarkup = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 0x80) != 0)
     {
         this.entities = StreamingUtils.readTLVector(stream, context);
     }
     if ((this.flags & 0x400) != 0)
     {
         this.views = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 0x8000) != 0)
     {
         this.editDate = StreamingUtils.readInt(stream);
     }
 }
Пример #18
0
        public ActionResult Home()
        {
            IList <Edge> edges;
            IList <City> cities2;

            using (var context = new TLContext())
            {
                edges   = context.GetAllEdges();
                cities2 = context.GetCities().ToList();
            }
            var cities    = MappingService.GetCities();
            var dtoCities = new List <CityDTO>();

            foreach (var city in cities)
            {
                dtoCities.Add(new CityDTO()
                {
                    Id   = city.ID,
                    Name = city.Name
                });
            }

            var parcelTypes    = MappingService.GetParcelTypes();
            var dtoParcelTypes = new List <ParcelTypeDTO>();

            foreach (var parcelType in parcelTypes)
            {
                dtoParcelTypes.Add(new ParcelTypeDTO()
                {
                    Id   = parcelType.ID,
                    Name = parcelType.Name
                });
            }

            var model = new HomeDTO
            {
                SourceCitites      = dtoCities,
                DestinationCitites = dtoCities,
                ParcelTypes        = dtoParcelTypes
            };

            return(View(model));
        }
Пример #19
0
        public override void deserializeBody(InputStream stream, TLContext context)
        {
            int num = StreamingUtils.readInt(stream);

            this.messages.clear();
            int num2 = 0;

            while (true)
            {
                if (num2 >= num)
                {
                    break;
                }
                MTMessage message = new MTMessage();
                message.deserializeBody(stream, context);
                this.messages.add(message);
                num2++;
            }
        }
Пример #20
0
        public TelegramClient(int apiId, string apiHash,
                              Session session = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null)
        {
            if (apiId == default(int))
            {
                throw new MissingApiConfigurationException("API_ID");
            }
            if (string.IsNullOrEmpty(apiHash))
            {
                throw new MissingApiConfigurationException("API_HASH");
            }

            TLContext.Init();
            _apiHash = apiHash;
            _apiId   = apiId;
            _handler = handler;

            _session   = Session.GetSession(session?.Store ?? new FileSessionStore(), session?.SessionUserId ?? sessionUserId, session);
            _transport = new TcpTransport(_session.ServerAddress, _session.Port, _handler);
        }
Пример #21
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     this.user  = StreamingUtils.readTLObject(stream, context);
     if ((this.flags & 2) != 0)
     {
         this.about = StreamingUtils.readTLString(stream);
     }
     this.link = StreamingUtils.readTLObject(stream, context);
     if ((this.flags & 4) != 0)
     {
         this.profilePhoto = StreamingUtils.readTLObject(stream, context);
     }
     this.notifySettings = StreamingUtils.readTLObject(stream, context);
     if ((this.flags & 8) != 0)
     {
         this.botInfo = StreamingUtils.readTLObject(stream, context);
     }
     this.commonChatsCount = StreamingUtils.readInt(stream);
 }
Пример #22
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     base.id    = StreamingUtils.readInt(stream);
     if ((this.flags & 0x2000) != 0)
     {
         this.accessHash = StreamingUtils.readLong(stream);
     }
     this.title = StreamingUtils.readTLString(stream);
     if ((this.flags & 0x40) != 0)
     {
         this.username = StreamingUtils.readTLString(stream);
     }
     this.photo   = StreamingUtils.readTLObject(stream, context);
     this.date    = StreamingUtils.readInt(stream);
     this.version = StreamingUtils.readInt(stream);
     if ((this.flags & 0x200) != 0)
     {
         this.restrictionReason = StreamingUtils.readTLString(stream);
     }
 }
Пример #23
0
        public override void deserializeBody(InputStream stream, TLContext context)
        {
            this.requestId = StreamingUtils.readLong(stream);
            this.now       = StreamingUtils.readInt(stream);
            int num = StreamingUtils.readInt(stream);

            this.salts.clear();
            int num2 = 0;

            while (true)
            {
                if (num2 >= num)
                {
                    break;
                }
                MTFutureSalt t = new MTFutureSalt();
                t.deserializeBody(stream, context);
                this.salts.add(t);
                num2++;
            }
        }
Пример #24
0
        public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session")
        {
            if (apiId == default(int))
            {
                throw new MissingApiConfigurationException("API_ID");
            }
            if (string.IsNullOrEmpty(apiHash))
            {
                throw new MissingApiConfigurationException("API_HASH");
            }

            if (store == null)
            {
                store = new FileSessionStore();
            }

            TLContext.Init();
            _apiHash = apiHash;
            _apiId   = apiId;

            _session   = Session.TryLoadOrCreateNew(store, sessionUserId);
            _transport = new TcpTransport(_session.ServerAddress, _session.Port);
        }
Пример #25
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     this.id    = StreamingUtils.readTLString(stream);
     this.type  = StreamingUtils.readTLString(stream);
     if ((this.flags & 1) != 0)
     {
         this.photo = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 2) != 0)
     {
         this.document = StreamingUtils.readTLObject(stream, context);
     }
     if ((this.flags & 4) != 0)
     {
         this.title = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 8) != 0)
     {
         this.description = StreamingUtils.readTLString(stream);
     }
     this.sendMessage = StreamingUtils.readTLObject(stream, context);
 }
Пример #26
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.flags = StreamingUtils.readInt(stream);
     this.id    = StreamingUtils.readTLString(stream);
     this.type  = StreamingUtils.readTLString(stream);
     if ((this.flags & 2) != 0)
     {
         this.title = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 4) != 0)
     {
         this.description = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 8) != 0)
     {
         this.url = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x10) != 0)
     {
         this.thumbUrl = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x20) != 0)
     {
         this.contentUrl  = StreamingUtils.readTLString(stream);
         this.contentType = StreamingUtils.readTLString(stream);
     }
     if ((this.flags & 0x40) != 0)
     {
         this.w = StreamingUtils.readInt(stream);
         this.h = StreamingUtils.readInt(stream);
     }
     if ((this.flags & 0x80) != 0)
     {
         this.duration = StreamingUtils.readInt(stream);
     }
     this.sendMessage = StreamingUtils.readTLObject(stream, context);
 }
Пример #27
0
        public static TLBytes readTLBytes(InputStream stream, TLContext context)
        {
            int num3;
            int expressionStack_5B_0;
            int size = stream.read();
            int num2 = 1;

            if (size >= 0xfe)
            {
                size = (stream.read() + (stream.read() << 8)) + (stream.read() << 0x10);
                num2 = 4;
            }
            TLBytes bytes = context.allocateBytes(size);

            readBytes(bytes.getData(), bytes.getOffset(), bytes.getLength(), stream);
            if (4 != -1)
            {
                int expressionStack_5A_1 = size + num2;
                int expressionStack_5A_0 = 4;
                expressionStack_5B_0 = expressionStack_5A_1 % expressionStack_5A_0;
                goto Label_005B;
            }
            else
            {
                int expressionStack_55_1 = size + num2;
            }
            expressionStack_5B_0 = 0;
Label_005B:
            num3 = expressionStack_5B_0;
            if (num3 != 0)
            {
                int count = 4 - num3;
                skipBytes(count, stream);
            }
            return(bytes);
        }
Пример #28
0
        /**
         * Reading tl-bytes from stream with manual allocation
         *
         * @param stream  source stream
         * @param context tl-context
         * @return readed bytes
         * @throws IOException reading exception
         */
        public static TLBytes readTLBytes(/*InputStream*/ BufferedStream  stream, TLContext context)
        {
            try {
            //                int count = /*stream.read();*/ stream.Read();
                byte[] byte_count = new byte[] { };
                stream.Read(byte_count, 0, (int)stream.Length);
                int count = Convert.ToInt32(byte_count);
                int a = Convert.ToInt32(byte_count);
                int b = Convert.ToInt32(byte_count);
                int c = Convert.ToInt32(byte_count);

                int startOffset = 1;
                if (count >= 254) {
                    count = /*stream.Read()*/a + (/*stream.Read()*/b << 8) + (/*stream.Read()*/c << 16);
                    startOffset = 4;
                }
                TLBytes res = context.allocateBytes(count);
                readBytes(res.getData(), res.getOffset(), res.getLength(), stream);

                int offset = (count + startOffset) % 4;
                if (offset != 0) {
                    int offsetCount = 4 - offset;
                    skipBytes(offsetCount, stream);
                }
                return res;
            } catch(IOException e) {
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
                throw e;
            }
        }
Пример #29
0
 /**
  * Reading tl-vector from stream
  *
  * @param stream  source stream
  * @param context tl-context
  * @return tl-vector
  * @throws IOException reading exception
  */
 /*TLVector*/
 public static TLObject readTLVector(/*InputStream*/ BufferedStream  stream, TLContext context)
 {
     try {
         return (TLObject)context.deserializeVector<Object>(stream);
     } catch(IOException e) {
         System.Diagnostics.Debug.WriteLine(e.StackTrace);
         throw e;
     }
 }
Пример #30
0
 public override void deserializeBody(System.IO.BufferedStream stream, TLContext context) { }
Пример #31
0
 override public void deserializeBody(BufferedStream stream, TLContext context) {
     validSince = StreamingUtils.readInt(stream);
     validUntil = StreamingUtils.readInt(stream);
     salt = StreamingUtils.readLong(stream);
 }
Пример #32
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.channelId = StreamingUtils.readInt(stream);
 }
Пример #33
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.nonce        = StreamingUtils.readBytes(0x10, stream);
     this.serverNonce  = StreamingUtils.readBytes(0x10, stream);
     this.newNonceHash = StreamingUtils.readBytes(0x10, stream);
 }
Пример #34
0
 override public void deserializeBody(BufferedStream stream, TLContext context) {
     dcId = StreamingUtils.readInt(stream);
     address = StreamingUtils.readTLString(stream);
     port = StreamingUtils.readInt(stream);
     version = StreamingUtils.readInt(stream);
 }
Пример #35
0
 public virtual TLObject <bridge> deserializeResponse(InputStream @is, TLContext tlc) =>
 this.deserializeResponse(@is, tlc);
Пример #36
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.key = StreamingUtils.readTLObject(stream, context);
 }
Пример #37
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.msg_id = Long.valueOf(StreamingUtils.readLong(stream));
     this.seq_no = StreamingUtils.readInt(stream);
     this.bytes  = StreamingUtils.readInt(stream);
 }
Пример #38
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.packedData = StreamingUtils.readTLBytes(stream);
 }
Пример #39
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     base.id = StreamingUtils.readInt(stream);
 }
Пример #40
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.offset = StreamingUtils.readInt(stream);
     this.length = StreamingUtils.readInt(stream);
 }
Пример #41
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.id      = StreamingUtils.readTLObject(stream, context);
     this.caption = StreamingUtils.readTLString(stream);
 }
Пример #42
0
 public override void deserializeBody(InputStream stream, TLContext context)
 {
     this.lat = StreamingUtils.readDouble(stream);
     this.lon = StreamingUtils.readDouble(stream);
 }
Пример #43
-1
        public TelegramClient(int apiId, string apiHash, ISessionStore store = null, string sessionUserId = "session")
        {
            if (store == null)
            {
                store = new FileSessionStore();
            }

            TLContext.Init();
            _apiHash = apiHash;
            _apiId   = apiId;
            if (_apiId == 0)
            {
                throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");
            }

            if (string.IsNullOrEmpty(_apiHash))
            {
                throw new InvalidOperationException("Your API_ID is invalid. Do a configuration first https://github.com/sochix/TLSharp#quick-configuration");
            }
            _session   = Session.TryLoadOrCreateNew(store, sessionUserId);
            _transport = new TcpTransport(_session.ServerAddress, _session.Port);
        }