Returns an AuthKey instance associated with the saved
data center, or undefined if a new one should be generated.
Returns an AuthKey instance associated with the saved
data center, or undefined if a new one should be generated.
Returns the currently-used data center ID.
Returns the port to which the library should connect to.
Returns the server address where the library should connect to.
Called on client disconnection. Should be used to free any used resources. Can be left empty if none.
Called upon client.logOut(). Should delete the stored information from disk since it's not valid anymore.
gets auth key for a dc
OptionaldcId: numberTurns the given key into an InputPeer (e.g. InputPeerUser).
The library uses this method whenever an InputPeer is needed
to suit several purposes (e.g. user only provided its ID or wishes
to use a cached username to avoid extra RPC).
Called before using the session
Processes the input TLObject or list and saves
whatever information is relevant (e.g., ID or access hash).
May be asynchronous; the library awaits the result where possible,
and a storage failure never fails the request that produced it.
called whenever important properties change. It should make persist the relevant session information to disk.
sets auth key for a dc
OptionalauthKey: AuthKeyOptionaldcId: numberSets the information of the data center address and port that the library should connect to, as well as the data center ID, which is currently unused.
{number}
{string}
{number}
Persistent session that stores auth keys and entity data on disk using
node-localstorage.Creates a directory named after the session in the current working directory. Suitable for long-running server applications where session data must survive restarts.
Example