<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _on_connect(self, sequence, topic, message):
 """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 """


        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)