Пример #1
0
        public void read(BinaryReader reader) {
            logger.info("read session...");
            id = reader.ReadUInt64();
            sequence = reader.ReadInt32();
            mainDcId = reader.ReadInt32();
            timeOffset = reader.ReadInt32();
            cachedSalt = reader.ReadUInt64();
            int count = reader.ReadInt32();

            // contacts sync marker
            ContactsStateMarker = Serializers.String.read(reader);

            dcs = new Dictionary<int, TelegramDC>(count);
            for(int i = 0; i < count; i++) {
                int endpointId = reader.ReadInt32();
                dcs.Add(endpointId, new TelegramDC(reader));
            }

            int authorizationExists = reader.ReadInt32();
            if(authorizationExists != 0) {
                authorization = (Auth_authorizationConstructor) TL.Parse<auth_Authorization>(reader);
            }


            int usersCount = reader.ReadInt32();
            users = new Dictionary<int, UserModel>(usersCount + 10);
            for (int i = 0; i < usersCount; i++) {
                users.Add(reader.ReadInt32(), new UserModel(TL.Parse<User>(reader)));
            }

            int chatsCount = reader.ReadInt32();
            chats = new Dictionary<int, ChatModel>(chatsCount + 10);
            for (int i = 0; i < chatsCount; i++) {
                chats.Add(reader.ReadInt32(), new ChatModel(TL.Parse<Chat>(reader)));
            }

            logger.info("reading updates state....");
            updates = new UpdatesProcessor(this, reader);

            logger.info("reading dialogs...");
            dialogs = new Dialogs(this, reader);
            
            files = new Files(this);
            encryptedChats = new EncryptedChats(this, reader);

            logger.info("session readed complete");
        }
Пример #2
0
        public TelegramSession(ulong id, int sequence) {
            this.id = id;
            this.sequence = sequence;
            dcs = new Dictionary<int, TelegramDC>();
            updates = new UpdatesProcessor(this);
            dialogs = new Dialogs(this);
            files = new Files(this);
            encryptedChats = new EncryptedChats(this);
            users = new Dictionary<int, UserModel>();
            chats = new Dictionary<int, ChatModel>();

            SubscribeToUpdates();
        }