def version(self, value): self._version = version = StompSpec.version(value) self._heartbeat = None if self._version == StompSpec.VERSION_1_0 else StompHeartBeat() self._commands = StompSpec.COMMANDS[version] self._commandsBodyAllowed = StompSpec.COMMANDS_BODY_ALLOWED[self.version] self._codec = StompSpec.codec(version) self._stripLineDelimiter = StompSpec.STRIP_LINE_DELIMITER.get(version, '') self._findHead = re.compile(2 * ('%s?%s' % (self._stripLineDelimiter, StompSpec.LINE_DELIMITER) if self._stripLineDelimiter else StompSpec.LINE_DELIMITER).encode()).search
def version(self, value): self._version = version = StompSpec.version(value) codec = StompSpec.codec(version) self._encode = lambda text: text.encode(codec)