theturtle32 / WebSocket-Node

A WebSocket Implementation for Node.JS (Draft -08 through the final RFC 6455)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue in W3CWebSocket constructor

ibc opened this issue · comments

Hi, unfortunately some browsers (or similar devices) do not accept passing more than 2 arguments to the native WebSocket class. For example I get this error in Cordova:

Failed to construct 'WebSocket': No matching constructor signature.

This is because the official W3C WebSocket constructor just allows two arguments (WS URI and protocols), but in W3CWebSocket class we pass more arguments (those tha are useful when running in Node).

This is the way in which ws solves this problem:

https://github.com/einaros/ws/blob/master/lib/browser.js

I will apply it and send a PR.