class_docstr: Class that represents one Telnet connection.
code: def __init__(
      self,
      conn: socket.socket,
      addr: tuple[str, int],
      interact: Callable[[TelnetConnection], Coroutine[Any, Any, None]],
      server: TelnetServer,
      encoding: str,
      style: BaseStyle | None,
      vt100_input: PipeInput,
      enable_cpr: bool = True,
  ) -> None:
      self.conn = conn
      self.addr = addr
      self.interact = interact
      self.server = server
      self.encoding = encoding
      self.style = style
      self._closed = False
      self._ready = asyncio.Event()
      self.vt100_input = vt100_input
      self.enable_cpr = enable_cpr
      self.vt100_output: Vt100_Output | None = None
  
      # Create "Output" object.
      self.size = Size(rows=40, columns=79)
  
      # Initialize.
      _initialize_telnet(conn)
  
      # Create output.
      def get_size() -> Size:
          return self.size
  
      self.stdout = cast(
          TextIO, _ConnectionStdout(conn, encoding=encoding)
      )
  
      def data_received(data: bytes) -> None:
          """TelnetProtocolParser 'data_received' callback"""
          self.vt100_input.send_bytes(data)
  
      def size_received(rows: int, columns: int) -> None:
          """TelnetProtocolParser 'size_received' callback"""
          self.size = Size(rows=rows, columns=columns)
          if self.vt100_output is not None and self.context:
              self.context.run(lambda: get_app()._on_resize())
  
      def ttype_received(ttype: str) -> None:
          """TelnetProtocolParser 'ttype_received' callback"""
          self.vt100_output = Vt100_Output(
              self.stdout, get_size, term=ttype, enable_cpr=enable_cpr
          )
          self._ready.set()
  
      self.parser = TelnetProtocolParser(
          data_received, size_received, ttype_received
      )
      self.context: contextvars.Context | None = None
  
imports: from __future__ import annotations
  import asyncio
  import contextvars
  import socket
  from asyncio import get_running_loop
  from typing import Any, Callable, Coroutine, TextIO, cast
  from prompt_toolkit.application.current import create_app_session, get_app
  from prompt_toolkit.application.run_in_terminal import run_in_terminal
  from prompt_toolkit.data_structures import Size
  from prompt_toolkit.formatted_text import AnyFormattedText, to_formatted_text
  from prompt_toolkit.input import PipeInput, create_pipe_input
  from prompt_toolkit.output.vt100 import Vt100_Output
  from prompt_toolkit.renderer import print_formatted_text
  from prompt_toolkit.styles import BaseStyle, DummyStyle
  from .log import logger
  from .protocol import DO, ECHO, IAC, LINEMODE, MODE, NAWS, SB, SE, SEND, SUPPRESS_GO_AHEAD, TTYPE, WILL, TelnetProtocolParser
label_desc: Use image node_id 1 to create a new TelnetConnection object  with example: obj = TelnetConnection(conn, addr, interact, server, encoding, style, vt100_input, enable_cpr)