code: def _on_connect(self, sequence, topic, message):
          
  
          try:
              slug = None
              parts = topic.split('/')
              slug = parts[-3]
              uuid = self._extract_device_uuid(slug)
          except Exception:
              self._logger.exception("Error parsing slug from connection request (slug=%s, topic=%s)", slug, topic)
              return
  
          if messages.ConnectCommand.matches(message):
              key = message['key']
              client = message['client']
  
              self._loop.add_callback(self._connect_to_device, uuid, key, client)
          else:
              self._logger.warn("Unknown message received on connect topic=%s, message=%s", topic, message)
docs: Process a request to connect to an IOTile device
  
          A connection message triggers an attempt to connect to a device,
          any error checking is done by the DeviceManager that is actually
          managing the devices.
  
          A disconnection message is checked to make sure its key matches
          what we except for this device and is either discarded or
          forwarded on to the DeviceManager.
          Args:
              sequence (int): The sequence number of the packet received
              topic (string): The topic this message was received on
              message_type (string): The type of the packet received
              message (dict): The message itself