Pusher.com client for Espruino

Posted on
  • Does any one knows how to integrate pusher.com client to espruino ?


    All help is Appreciated.

  • This might be what you need? https://github.com/AverageMarcus/pusher-­websocket-espruino

    I'm not sure if Marcus is on the forum or not, but he comes to JSOxford stuff I could probably prod him if you're having problems?

  • thanks for the quick response, much appreciated. I will give it try and let you know.

  • I tried downloading the Pusher.js from GitHub and put it in the sandbox directory, then I uploaded the code from right-hand side of the IDE, but still getting following error,

    Uncaught ReferenceError: "Pusher" is not defined
    at line 1 col 5
    new Pusher(PUSHER_KEY, {}, function(pusher) {

    Can anyone help?

    new Pusher(PUSHER_KEY, {}, function(pusher) {
      var testChannel = pusher.subscribe('test_channel');
      testChannel.bind('my_event', function(data) {
        console.log('Got a message:', data);
  • Try var Pusher = require("Pusher"); at the top?

  • Hi @Gordon, thanks for the quick response, that helps but now I am getting a different error message, Any ideas?

    Uncaught Error: Field or method "data" does not already exist, and can't create it on undefined
     at line 1 col 39
    ...parse(a);var b=JSON.parse(a.data);this.socketId=b.soc­ket_id,...
    in function called from system
  • I think you might have to ask Marcus who wrote it - maybe file an issue on the Github page?

    Looks to me like it's failing here: https://github.com/AverageMarcus/pusher-­websocket-espruino/blob/master/pusher.js­#L89

    It's expecting data from the WebSocket 'open' handler, but the handler will never supply any data. I guess it's possible that he modified the websocket code and never committed his changes.

    However: you could try just deleting these 3 lines? https://github.com/AverageMarcus/pusher-­websocket-espruino/blob/master/pusher.js­#L88-90

    Thst might fix it

  • You are awesome! That fixed it!

    Thank you so much @Gordon.

    Got a message: {
      "message": "hello world"
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Pusher.com client for Espruino

Posted by Avatar for navas @navas