Added an onClose event into the class NetworkClient