浏览器发送(发布)消息和接收消息

发送(发布)消息

Java

    GoEasy goEasy = new GoEasy( "http(s)://<REST Host>”, "my_appkey");
    goEasy.publish("my_channel","Hello, GoEasy!");

JavaScript

    var goEasy = new GoEasy({
        appkey: "my_appkey"
    });
    //GoEasy-OTP可以对appkey进行有效保护,详情请参考​ ​ 
    goEasy.publish({
        channel: "my_channel",
        message: "Hello, GoEasy!"
    });

GoEasy-OTP

接收(订阅)消息

JavaScript

    var goEasy = new GoEasy({
        appkey: "my_appkey"
    });
    goEasy.subscribe({
        channel: "my_channel",
        onMessage: function (message) {
            alert("Channel:" + message.channel + " content:" + message.content);
        }
    });

取消订阅

JavaScript

    goEasy.unsubscribe ({
        channel: "my_channel"
    });

results matching ""

    No results matching ""