code: def _handle_message_for_stream(self, stream_transport, message, timeout):
      
      if message.command not in ('OKAY', 'CLSE', 'WRTE'):
        raise usb_exceptions.AdbProtocolError(
            '%s received unexpected message: %s', self, message)
  
      if message.arg1 == stream_transport.local_id:
        # Ack writes immediately.
        if message.command == 'WRTE':
          # Make sure we don't get a WRTE before an OKAY/CLSE message.
          if not stream_transport.remote_id:
            raise usb_exceptions.AdbProtocolError(
                '%s received WRTE before OKAY/CLSE: %s',
                stream_transport, message)
          self.transport.write_message(adb_message.AdbMessage(
              'OKAY', stream_transport.local_id, stream_transport.remote_id),
                                       timeout)
        elif message.command == 'CLSE':
          self.close_stream_transport(stream_transport, timeout)
        return message
      else:
        # Message was not for this stream, add it to the right stream's queue.
        with self._stream_transport_map_lock:
          dest_transport = self._stream_transport_map.get(message.arg1)
  
        if dest_transport:
          if message.command == 'CLSE':
            self.close_stream_transport(dest_transport, timeout)
          dest_transport.enqueue_message(message, timeout)
        else:
          _LOG.warning('Received message for unknown local-id: %s', message)
docs: Handle an incoming message, check if it's for the given stream.
  
      If the message is not for the stream, then add it to the appropriate
      message queue.
  
      Args:
        stream_transport: AdbStreamTransport currently waiting on a message.
        message: Message to check and handle.
        timeout: Timeout to use for the operation, should be an instance of
          timeouts.PolledTimeout.
  
      Returns:
        The message read if it was for this stream, None otherwise.
  
      Raises:
        AdbProtocolError: If we receive an unexpected message type.