# generated by scripts/generate_messages.py

from twnet_parser.pretty_print import PrettyPrint
from twnet_parser.packer import Unpacker
from twnet_parser.packer import pack_int
from typing import Literal

class MsgRequestInfo(PrettyPrint):
    def __init__(
            self,
            token: int = 0
    ) -> None:
        self.message_type: Literal['connless'] = 'connless'
        self.message_name: str = 'connless.request_info'
        self.message_id: list[int] = [255, 255, 255, 255, 103, 105, 101, 51]

        self.token: int = token

    def __iter__(self):
        yield 'message_type', self.message_type
        yield 'message_name', self.message_name
        yield 'message_id', self.message_id

        yield 'token', self.token

    # first byte of data
    # has to be the first byte of the message payload
    # NOT the chunk header and NOT the message id
    def unpack(self, data: bytes) -> bool:
        unpacker = Unpacker(data)
        self.token = unpacker.get_int()
        return True

    def pack(self) -> bytes:
        return pack_int(self.token)