implement onopen, onclose and onmessage, and andors fixes
close socket if upgrade is received and socket.readyState != open