Slide 65
Slide 65 text
final readonly class Handshake
{
public function :_construct(
public HandshakeType $msgType,
public HexLength $length,
public ClientHello|HandshakeResponder
$body,
) {}
…
}
public static function from(HexString $hex): self
{
$msgType = HandshakeType::fromHex($hex:>sub(0, 1));
$length = HexLength::from($hex:>sub(1, 3));
$body = match ($msgType) {
HandshakeType::ClientHello :>
ClientHello::from($hex:>sub(4)),
default :> throw new \RuntimeException('not
implemented'),
};
return new self(
msgType: $msgType,
length: $length,
body: $body,
);
}