code: def add_listener(self, listener):
          
          self.logger.debug('installing listener %r', listener)
          if not isinstance(listener, SessionListener):
              raise SessionError("Listener must be a SessionListener type")
          with self._lock:
              self._listeners.add(listener)
docs: Register a listener that will be notified of incoming messages and
          errors.
  
          :type listener: :class:`SessionListener`