maxogden/websocket-stream — pull request #3 by ZauberNerd (2013-02-17 08:01:16+00:00)
Title: Register onopen callback and emit 'open' event when connection is established.

Register onopen callback and emit 'open' event when connection is established.

```
var websocket = require('websocket-stream')
var ws = websocket('ws://realtimecats.com')

// case #1
ws.write('stuff')
// fails with the following DOM Exception ( http://stackoverflow.com/a/14733149/1524161 ):
// Uncaught Error: INVALID_STATE_ERR: DOM Exception 11 bundle.js:1515
// WebsocketStream.write bundle.js:1515
// (anonymous function) bundle.js:1531
// require.modules.(anonymous function) bundle.js:182
// require bundle.js:8
// (anonymous function) bundle.js:1550
// (anonymous function) bundle.js:1551

// case #2
ws.on('open', function () {
console.log('connection is established, sending stuff to server'):
ws.write('stuff');
});
// works
```