strophe / strophejs

Strophe.js is an XMPP library for JavaScript

Home Page:http://strophe.im/strophejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Not working with Node.js

EliSnow opened this issue · comments

Despite some recent PRs it looks like Strophe (as of version 1.4.1) is not working with Node.js.

The following error occurs when calling the connect method on a Connection object:

  ReferenceError: window is not defined
      at Request._newXHR (/REDACTED/node_modules/strophe.js/dist/strophe.common.js:4843:7)
      at new Request (/REDACTED/node_modules/strophe.js/dist/strophe.common.js:4780:21)
      at Bosh._connect (/REDACTED/node_modules/strophe.js/dist/strophe.common.js:4986:27)
      at Connection.connect (/REDACTED/node_modules/strophe.js/dist/strophe.common.js:2628:19)

A comment in another issue notes there may be window references in other locations as well. This issue is intended to be broad enough to capture this and any other problems preventing Strophe from working in Node.js.

I use xhr = new plus.net.XMLHttpRequest(); to replace the original code and it works, plus.net is from Html5+ SDK

I've recently added tests to run Strophe in Node.js and fixed various issues, including window being used.

Should be released soon.