跳到主要内容
CNode
查看回复

回复 (2)

I
im-here#29 年前
    var client = new Paho.MQTT.Client("home.appxc.com", Number(10100), ""+Math.random())
    client.onMessageArrived = function(message) { window.vm.messages.push(JSON.parse(message.payloadString).content)}
    client.connect({useSSL:true, onSuccess:function(){ client.subscribe("public")}})
    window.vm=new Vue({
        el:'body>div',
        data:{messages:[], tosend:''},
        methods:{
            send:function(){
                if(this.tosend == "") return
                var payload = ({content:this.tosend})
                var message = new Paho.MQTT.Message(JSON.stringify(payload))
                message.destinationName = "public"
                client.send(message)
                this.tosend = ""
            }
        }
    })
	````
I
ipengyo#19 年前

然后呢 源码呢。。

参与回复

登录后即可参与回复。登录