2
0
mirror of https://github.com/esiur/esiur-dart.git synced 2025-05-06 12:02:57 +00:00

authorizedAccount

This commit is contained in:
Ahmed Zamil 2024-06-22 14:50:10 +03:00
parent 26794f08e7
commit 09c730ebc4
2 changed files with 23 additions and 3 deletions

View File

@ -1158,6 +1158,7 @@ class DistributedConnection extends NetworkConnection with IStore {
else if (_authPacket.event == IIPAuthPacketEvent.IndicationEstablished)
{
session.id = _authPacket.sessionId;
session.authorizedAccount = _authPacket.accountId!.getString(0, _authPacket.accountId!.length);
_ready = true;
_status = ConnectionStatus.Connected;
@ -1166,7 +1167,7 @@ class DistributedConnection extends NetworkConnection with IStore {
if (this.instance == null)
{
Warehouse.put(this.hashCode.toString().replaceAll("/", "_"), this, null, server).then((x)
Warehouse.put(session.authorizedAccount!.replaceAll("/", "_"), this, null, server).then((x)
{
_openReply?.trigger(true);
@ -1626,10 +1627,14 @@ class DistributedConnection extends NetworkConnection with IStore {
session.id = n;
var accountId = DC.stringToBytes(session.authorizedAccount!);
_sendParams()
..addUint8(IIPAuthPacketEvent.IndicationEstablished)
..addUint8(n.length)
..addDC(n)
..addUint8(accountId.length)
..addDC(accountId)
..done();
if (this.instance == null)

View File

@ -49,7 +49,8 @@ class IIPAuthPacket {
DC? challenge;
DC? asymetricEncryptionKey;
DC? sessionId;
DC? accountId;
TransmissionType? dataType;
int reference = 0;
@ -298,7 +299,7 @@ class IIPAuthPacket {
} else if (event == IIPAuthPacketEvent.IndicationEstablished) {
if (_notEnough(offset, ends, 1))
if (_notEnough(offset, ends, 2))
return -_dataLengthNeeded;
var sessionLength = data[offset++];
@ -310,6 +311,20 @@ class IIPAuthPacket {
offset += sessionLength;
if (_notEnough(offset, ends, 1))
return -_dataLengthNeeded;
var accountLength = data[offset++];
if (_notEnough(offset, ends, accountLength))
return -_dataLengthNeeded;
accountId = data.clip(offset, accountLength);
offset += accountLength;
} else if (event == IIPAuthPacketEvent.IAuthPlain ||
event == IIPAuthPacketEvent.IAuthHashed ||
event == IIPAuthPacketEvent.IAuthEncrypted) {