服务信息推送
消息入棧
GoEasy goEasy = new GoEasy("host","my_appkey"); goEasy.publish("my_channel","Hello, GoEasy!");host:服務名
my_appkey:秘鑰
my_channel:消息頻道
消息接收
<script src="http://cdn-hangzhou.goeasy.io/goeasy.js"></script>var goEasy = new GoEasy({appkey: "my_appkey" }); // 接收my_channel頻道的信息 goEasy.subscribe({channel: "my_channel",onMessage: function (message) {console.log(message.content);} });導包引入
pom文件添加
<!-- 倉庫添加 --> <repositories><repository><id>goeasy</id><name>goeasy</name><url>http://maven.goeasy.io/content/repositories/releases/</url></repository> </repositories> <!-- jar包依賴 --> <dependencies><dependency><groupId>io.goeasy</groupId><artifactId>goeasy-sdk</artifactId><version>0.3.8</version></dependency> </dependencies>對應jar包依賴: goeasy-sdk.jar, gson-2.3.1.jar,slf4j-api-1.7.2.jar
代碼案例
Java后臺代碼
String host = "http://rest-hangzhou.goeasy.io"; String my_appkey = "BC-78534f92f1204dd595be0e4cbdb8714b"; GoEasy goEasy = new GoEasy( host,my_appkey ); goEasy.publish("my_channel","Hello, GoEasy!");前臺js接收
<script src="http://cdn-hangzhou.goeasy.io/goeasy.js"></script> <script type="text/javascript">var goEasy = new GoEasy({ appkey: "BC-78534f92f1204dd595be0e4cbdb8714b"}); goEasy.subscribe({channel: "my_channel", onMessage: function (message) {alert("Channel:" + message.channel + " content:" + message.content);}}); </script> 與50位技術專家面對面20年技術見證,附贈技術全景圖總結
- 上一篇: Redis 修改密码
- 下一篇: nginx 配置详解