mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Alternate simpler byte[] callback session store
This commit is contained in:
parent
288bf7ccf7
commit
125c1caeeb
|
|
@ -94,6 +94,9 @@ namespace WTelegram
|
|||
})
|
||||
{ }
|
||||
|
||||
public Client(Func<string, string> configProvider, byte[] startSession, Action<byte[]> saveSession)
|
||||
: this(configProvider, new ActionStore(startSession, saveSession)) { }
|
||||
|
||||
/// <summary>Welcome to WTelegramClient! 🙂</summary>
|
||||
/// <param name="configProvider">Config callback, is queried for: <b>api_id</b>, <b>api_hash</b>, <b>session_pathname</b></param>
|
||||
/// <param name="sessionStore">if specified, must support initial Length & Read() of a session, then calls to Write() the updated session. Other calls can be ignored</param>
|
||||
|
|
|
|||
|
|
@ -192,4 +192,11 @@ namespace WTelegram
|
|||
base.Write(_header, 0, 8);
|
||||
}
|
||||
}
|
||||
|
||||
// QWxp couldn't be bothered to write such a simple SessionStore, so here it is:
|
||||
internal class ActionStore(byte[] startSession, Action<byte[]> saveSession) : MemoryStream(startSession ?? Array.Empty<byte>())
|
||||
{
|
||||
public override void Write(byte[] buffer, int offset, int count) => saveSession(buffer[offset..(offset + count)]);
|
||||
public override void SetLength(long value) { }
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue