[typo] Fixed typo
[minor] Made it more clear when to emit a readyStateChange event
[minor] Add a reason to the `readyStateChange` event, makes debugging easier.
[minor] Move the buffering to _write instead of .write

By moving the buffering we can flush the messages faster when we have a connection
as no more additional processing needs to happen.

In addition to that it gives us a bigger opportunity to write data as the message
transformation takes time. And this time can be used to wait for a connection to
establish. So if you're lucky, you can directly send the message.