Add support for whenConnected as suggested in TwistedMatric issue 4735.