+# See RFC 6455 section 7.4
+websocket_status_to_message = (status) ->
+  switch status
+    when 1000 then return 'Normal closure'
+    when 1001 then return 'Endpoint is going away'
+    when 1002 then return 'WebSocket protocol error'
+    when 1003 then return 'Server received invalid data'
+  'Unknown status code or error'
+
 native_methods.java.net.PlainSocketImpl = [
   o 'socketCreate(Z)V', (rs, _this, isServer) ->
     # Check to make sure we're in a browser and the websocket libraries are present

      try
        _this.$ws.open host
      catch err
        error_cb('Connection failed! (exception)')
      
      
  o 'socketBind(Ljava/net/InetAddress;I)V', (rs, _this, address, port) ->

        resume_cb())
      
      # Error cases
      _this.$ws.on('close', close_cb('Connection failed! (Closed)'))
      
      # Timeout case
      id = window.setTimeout(error_cb('Connection timeout!'), timeout) if timeout > 0
