Adding onOpen and onClose for webSocket