Created
November 23, 2015 12:13
-
-
Save asonas/287fc80eb1c3e441525a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Subscriber | |
constructor: (topic) -> | |
@client = new Paho.MQTT.Client("m11.cloudmqtt.com", 33563, "web_" + parseInt(Math.random() * 100, 10)); | |
console.log topic | |
@topic = topic | |
connect: -> | |
options = | |
useSSL: true | |
userName: gon.username | |
password: gon.password | |
onSuccess: => | |
@client.subscribe(@topic) | |
@client.connect options | |
setMessageArrivedCallback: (callback) => | |
@client.onMessageArrived = callback | |
$ -> | |
snsSubscriver = new Subscriber("social-stream/tweet") | |
snsSubscriver.setMessageArrivedCallback( (message) -> | |
console.log message.payloadString | |
) | |
snsSubscriver.connect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment