eclipse / paho.mqtt.javascript

paho.mqtt.javascript
Other
1.15k stars 467 forks source link

Removed reference to window and change to self #116

Closed tmulkern closed 7 years ago

tmulkern commented 7 years ago

Removed reference to window and change to self. This is to allow the client to be used in Web Workers see: https://developer.mozilla.org/en/docs/Web/API/Window/self

Signed-off-by: Tadhg Mulkerntadhg.j.mulkern@gmail.com

tmulkern commented 7 years ago

I cannot see why the build is failing

tmulkern commented 7 years ago

It builds perfectly on my local machine, the build error seems to be about a plugin

/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/babylon/lib/index.js:115
      beforeExpr,
                ^
SyntaxError: Unexpected token ,
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Object.load (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/loader.js:112:15)
    at Requizzle.requizzle (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/requizzle.js:90:24)
    at infectProxy (/home/travis/build/eclipse/paho.mqtt.javascript/node_modules/jsdoc/node_modules/requizzle/lib/loader.js:82:28)
    at Module.targetModule.require ...
jpwsutton commented 7 years ago

Thanks for the contribution @tmulkern, just two changes please:

  1. Could you target this at the develop branch please?
  2. To fix the failing tests, you'll need to change global.window = global; to global.self = global; in client-harness.js. I've tested it locally and the tests then pass.
tmulkern commented 7 years ago

Done and Done, thanks for the help @jpwsutton

tmulkern commented 7 years ago

@jpwsutton the build is still failing with the original failure, any ideas?

tmulkern commented 7 years ago

@jpwsutton fixed the problem with the build, nobody specified the version of nodejs to run in .travis.yml. This cause problems with the bundling, in the build log the plugins stated that they needed a version of node greater that 4.2 (see here)

[INFO] --- exec-maven-plugin:1.2.1:exec (install-jsdoc-modules) @ paho.javascript ---
npm WARN package.json paho-client@ No repository field.
npm WARN engine jsdoc@3.5.4: wanted: {"node":">=4.2.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
npm WARN engine babylon@7.0.0-beta.20: wanted: {"node":">=4.2.0"} (current: {"node":"0.10.36","npm":"1.4.28"})
jsdoc@3.5.4 node_modules/jsdoc

So I set the version to be the latest version of 5.x

eval commented 6 years ago

@jpwsutton Instead of having the requirement for global.self, which makes the following fail:

(develop)$ node src/paho-mqtt.js
/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:2386
})(self);
   ^

ReferenceError: self is not defined
    at LibraryFactory (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:2386:4)
    at ExportLibrary (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:86:20)
    at Object.<anonymous> (/Users/gert/src/paho.mqtt.javascript/src/paho-mqtt.js:97:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)

How about setting this somewhere within: https://github.com/eval/paho.mqtt.javascript/commit/67e92a980b945b7c47252fd380a6616dd15a1e1c