Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electron support - condition for require('ws') #111

Open
manikantag opened this issue Dec 18, 2016 · 0 comments
Open

Electron support - condition for require('ws') #111

manikantag opened this issue Dec 18, 2016 · 0 comments

Comments

@manikantag
Copy link

manikantag commented Dec 18, 2016

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?

@manikantag manikantag changed the title Electron support - require('ws') Electron support - condition for require('ws') Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant