added public onopen and onclose handlers