Implements connected and disconnected events