class_docstr: Defines the protocol for chatting with starcraft.
docstr: Read a Response, do some validation, and return it.
docstr_tok: ["Read","a","Response",",","do","some","validation",",","and","return","it","."]
code: def read(self):
      """Read a Response, do some validation, and return it."""
      if FLAGS.sc2_verbose_protocol:
          self._log(
              "-------------- [%s] Reading response --------------",
              self._port,
          )
          start = time.time()
      response = self._read()
      if FLAGS.sc2_verbose_protocol:
          self._log(
              "-------------- [%s] Read %s in %0.1f msec --------------\n%s",
              self._port,
              response.WhichOneof("response"),
              1000 * (time.time() - start),
              self._packet_str(response),
          )
      if not response.HasField("status"):
          raise ProtocolError(
              "Got an incomplete response without a status."
          )
      prev_status = self._status
      self._status = Status(
          response.status
      )  # pytype: disable=not-callable
      if response.error:
          err_str = (
              "Error in RPC response (likely a bug). "
              "Prev status: %s, new status: %s, error:\n%s"
              % (prev_status, self._status, "\n".join(response.error))
          )
          logging.error(err_str)
          raise ProtocolError(err_str)
      return response
  
imports: import contextlib
  import enum
  import itertools
  import os
  import socket
  import sys
  import time
  from absl import flags
  from absl import logging
  from pysc2.lib import stopwatch
  import websocket
  from s2clientprotocol import sc2api_pb2
label_desc: Use image node_id 4 for calling the StarcraftProtocol obj's underlying member method code with example usage: obj.read() and returns: response