'Change the underlaying XML stream state
Stream starts with STREAM__NOT_OPENED and then proceeds with
STREAM__OPENED, STREAM__CLOSING and STREAM__CLOSED states.
Note that some features (like TLS and SASL)
requires stream re-start so this state can have non-linear changes.'

def set_stream_state(self, newstate):

    if (self._stream_state < newstate):
        self._stream_state = newstate
