def _set_state(self, state):
        """
        Transition the SCTP association to a new state.
        """
        if state != self._association_state:
            self.__log_debug('- %s -> %s', self._association_state, state)
            self._association_state = state

        if state == self.State.ESTABLISHED:
            self.__state = 'connected'
            for channel in list(self._data_channels.values()):
                if channel.negotiated and channel.readyState != 'open':
                    channel._setReadyState('open')
            asyncio.ensure_future(self._data_channel_flush())
        elif state == self.State.CLOSED:
            self._t1_cancel()
            self._t2_cancel()
            self._t3_cancel()
            self.__state = 'closed'

            # close data channels
            for stream_id in list(self._data_channels.keys()):
                self._data_channel_closed(stream_id)

            # no more events will be emitted, so remove all event listeners
            # to facilitate garbage collection.
            self.remove_all_listeners()
Transition the SCTP association to a new state.