   socket.addEventListener(
     "message"
     (event) =>
-      webkitPostMessage({ message: 'data', buffer: event.data })
+      webkitPostMessage({ message: 'data', buffer: event.data }, [ event.data ])
   )
 
 

      @socket.close()
      @socket = null


WebSocketImpl = if self.MozWebSocket then self.MozWebSocket else self.WebSocket

self.onmessage = (message) ->

  switch message.data.message


initialize = (url) ->

  socket = new WebSocket(url)
  socket.binaryType = 'arraybuffer'
      
  socket.onopen = ->
    postMessage({ message: 'open' })

  socket.onerror = (err) ->
    postMessage({ message: 'error', error: err.toString() })
     
  socket.addEventListener(
    "close" 
