Add connected and disconnected events.