'Register a callback to be called if our broker gets disconnected.
@param callback: a callable which will be called with one
argument, this instance.'

def notifyOnDisconnect(self, callback):

    assert callable(callback)
    self.disconnectCallbacks.append(callback)
    if (len(self.disconnectCallbacks) == 1):
        self.broker.notifyOnDisconnect(self._disconnected)
