-
• #2
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?
-
• #3
thanks for the quick response, much appreciated. I will give it try and let you know.
-
• #4
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?
require("Pusher"); var PUSHER_KEY = 'XXXXXXXXXXXXX'; new Pusher(PUSHER_KEY, {}, function(pusher) { var testChannel = pusher.subscribe('test_channel'); testChannel.bind('my_event', function(data) { console.log('Got a message:', data); }); });
-
• #5
Try
var Pusher = require("Pusher");
at the top? -
• #6
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.socket_id,... ^ in function called from system
-
• #7
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
Does any one knows how to integrate pusher.com client to espruino ?
https://pusher.com/docs/
All help is Appreciated.
Navas