class_docstr: Manages the Comm connection between IPython and the browser (client).
  
  Comms are 2 way, with the CommSocket being able to publish a message
  via the send_json method, and handle a message with on_message. On the
  JS side figure.send_message and figure.ws.onmessage do the sending and
  receiving respectively.
code: def __init__(self, manager):
      self.supports_binary = None
      self.manager = manager
      self.uuid = str(uuid.uuid4())
      # Publish an output area with a unique ID. The javascript can then
      # hook into this area.
      display(HTML("<div id=%r></div>" % self.uuid))
      try:
          self.comm = Comm("matplotlib", data={"id": self.uuid})
      except AttributeError as err:
          raise RuntimeError(
              "Unable to create an IPython notebook Comm "
              "instance. Are you in the IPython "
              "notebook?"
          ) from err
      self.comm.on_msg(self.on_message)
  
      manager = self.manager
      self._ext_close = False
  
      def _on_close(close_message):
          self._ext_close = True
          manager.remove_comm(close_message["content"]["comm_id"])
          manager.clearup_closed()
  
      self.comm.on_close(_on_close)
  
imports: from base64 import b64encode
  import io
  import json
  import pathlib
  import uuid
  from ipykernel.comm import Comm
  from IPython.display import display, Javascript, HTML
  from matplotlib import is_interactive
  from matplotlib._pylab_helpers import Gcf
  from matplotlib.backend_bases import _Backend, CloseEvent, NavigationToolbar2
  from .backend_webagg_core import FigureCanvasWebAggCore, FigureManagerWebAgg, NavigationToolbar2WebAgg
  from .backend_webagg_core import TimerTornado, TimerAsyncio
label_desc: Use image node_id 1 to create a new CommSocket object  with example: obj = CommSocket(manager)