25 public const NETWORK_ID = ProtocolInfo::LOGIN_PACKET;
28 public string $authInfoJson;
29 public string $clientDataJwt;
34 public static function create(
int $protocol,
string $authInfoJson,
string $clientDataJwt) : self{
36 $result->protocol = $protocol;
37 $result->authInfoJson = $authInfoJson;
38 $result->clientDataJwt = $clientDataJwt;
42 public function canBeSentBeforeLogin() : bool{
47 $this->protocol = BE::readUnsignedInt($in);
48 $this->decodeConnectionRequest(CommonTypes::getString($in));
51 protected function decodeConnectionRequest(
string $binary) : void{
52 $connRequestReader = new ByteBufferReader($binary);
54 $authInfoJsonLength = LE::readUnsignedInt($connRequestReader);
55 $this->authInfoJson = $connRequestReader->readByteArray($authInfoJsonLength);
57 $clientDataJwtLength = LE::readUnsignedInt($connRequestReader);
58 $this->clientDataJwt = $connRequestReader->readByteArray($clientDataJwtLength);
62 BE::writeUnsignedInt($out, $this->protocol);
63 CommonTypes::putString($out, $this->encodeConnectionRequest());
66 protected function encodeConnectionRequest() : string{
67 $connRequestWriter = new ByteBufferWriter();
69 LE::writeUnsignedInt($connRequestWriter, strlen($this->authInfoJson));
70 $connRequestWriter->writeByteArray($this->authInfoJson);
72 LE::writeUnsignedInt($connRequestWriter, strlen($this->clientDataJwt));
73 $connRequestWriter->writeByteArray($this->clientDataJwt);
75 return $connRequestWriter->getData();
79 return $handler->handleLogin($this);