Added onopened and onclosed event callback options.