Skip to content

Conversation

@knocte
Copy link
Member

@knocte knocte commented Oct 13, 2020

No description provided.

knocte and others added 2 commits October 12, 2020 20:39
It's always better to have a human-readable JSON
file than an unreadable DAT one containing bytes.

You can see what the session file contains, what
it is all about.

Also, it prevents the file from getting corrupted.
Happened to me a few times in the past using
FileSessionStore, had to delete the session file
and reconnect/auth.

And it's just way better in general for storing
data. For example, I currently store a lot of
sessions in a SQL database, and doing it with
bytes would have been a pain.

JSON session file is just better in general.
int sessionExpires = 0;
TLUser TLUser = null;
int userId = default;
if (isAuthExsist)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol that typo is not in my commit :P

{
sessionExpires = reader.ReadInt32();
TLUser = (TLUser)ObjectUtils.DeserializeObject(reader);
userId = (int)ObjectUtils.DeserializeObject (reader);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userId = reader.ReadInt32();

writer.Write(1);
writer.Write(SessionExpires);
ObjectUtils.SerializeObject(TLUser, writer);
ObjectUtils.SerializeObject (UserId, writer);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writer.write(UserId);

}
}
}
public bool AuthenticatedSuccessfully {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we don't have to save UserId at all because we can just run GetSelfUser and If we're not authenticated we get an error

knocte added a commit that referenced this pull request Oct 13, 2020
This will help implementing session storage in JSON
format. WIP PRs:
- #18
- #29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants