code: def _process(self, data):
          
          try:
              packet = json.loads(data)
          except ValueError:
              # So far, this never happened. But it would be good to have some
              # protection.
              logger.warning('Received invalid JSON from client. Ignoring.')
              return
  
          # Handle commands.
          if packet['cmd'] == 'run-command':
              self._run_command(packet)
  
          # Handle stdin.
          elif packet['cmd'] == 'in':
              self._pipeinput.send_text(packet['data'])
  
  #        elif packet['cmd'] == 'flush-input':
  #            self._inputstream.flush()  # Flush escape key.  # XXX: I think we no longer need this.
  
          # Set size. (The client reports the size.)
          elif packet['cmd'] == 'size':
              data = packet['data']
              self.size = Size(rows=data[0], columns=data[1])
              self.pymux.invalidate()
  
          # Start GUI. (Create CommandLineInterface front-end for pymux.)
          elif packet['cmd'] == 'start-gui':
              detach_other_clients = bool(packet['detach-others'])
              color_depth = packet['color-depth']
              term = packet['term']
  
              if detach_other_clients:
                  for c in self.pymux.connections:
                      c.detach_and_close()
  
              print('Create app...')
              self._create_app(color_depth=color_depth, term=term)
docs: Process packet received from client.