defer close while upgrading a transport
check readyState in sendPacket and close on upgradeError too
Merge pull request #324 from nkzawa/patch-5

Defer close while upgrading a transport