"""
Protected module contains RPC connection classes and parameters
"""

from abc import ABC


class RpcConnection(ABC):
    """
    Abstract base class representing a TCP/IP connection to a Blue server.

    Concrete implementations:

    * :class:`~ecmind_blue_client.rpc.sync_api.RpcSyncConnection` — synchronous (blocking socket).
    * :class:`~ecmind_blue_client.rpc.async_api.RpcAsyncConnection` — asynchronous (asyncio streams).

    Session state attributes are populated during the login sequence:

    * ``session_guid`` is set by ``krn.SessionAttach``.
    * ``user_guid``, ``user_id``, ``username``, ``unicode_system``, and ``pwd_expires``
      are set by ``krn.SessionLogin``.

    Args:
        hostname (str): The hostname or IP address of the Blue server.
        port (int): The TCP port of the Blue server.

    Attributes:
        session_guid (str | None): The session GUID assigned by the server after attach.
        user_guid (str | None): The user GUID assigned after login.
        user_id (int | None): The numeric user ID assigned after login.
        username (str | None): The authenticated username.
        unicode_system (bool | None): Whether the server operates in Unicode mode.
        pwd_expires (int | None): Password expiration timestamp (milliseconds since epoch).
    """

    def __init__(self, hostname: str, port: int):
        self._hostname = hostname
        self._port = port

    session_guid: str | None = None
    user_guid: str | None = None
    user_id: int | None = None
    username: str | None = None
    pwd_expires: int | None = None
    unicode_system: bool | None = None

    @property
    def hostname(self) -> str:
        """
        Returns:
            str: The hostname or IP address of the Blue server.
        """
        return self._hostname

    @property
    def port(self) -> int:
        """
        Returns:
            int: The TCP port of the Blue server.
        """
        return self._port
