PatrickJS/angular-websocket

Electron support - condition for require('ws')

manikantag opened this issue · 0 comments

Hi,

Now that developing Electron based apps is common, to support those apps, I think we better remove the check if (typeof window === 'undefined') as anyway it is in try/catch.

if (typeof window === 'undefined') { // removing this check would work in Browser, Node.js, Electron apps :)
  try {
    var ws = require('ws');

    Socket = (ws.Client || ws.client || ws);
  } catch(e) {}
}

(at github.com/AngularClass/angular-websocket/blob/master/src/angular-websocket.js#L5)

Due to this check, as Electron has 'window' in render process, it is not picking 'ws' module, and lacking many features 'ws' supports (like, auth).

I knew we can achieve basic auth with wss://user:pass@serverurl. But it does has more options.

Any thoughts?