BitShares Forum
Main => 中文 (Chinese) => Topic started by: alt on August 01, 2014, 03:00:50 pm
-
想写一个 blockchains explore,不会写 web 页面,谁有兴趣啊?
要求使用 html5 websocket 实现,
刚写了点后台数据,推送 block chain 列表。
测试地址: http://106.185.26.162:8000
firefox下打开 ctrl+shift+k 打开控制台可以看到数据
index.html
<!-- Import PubNub Core Lib -->
<script src="https://pubnub.a.ssl.fastly.net/pubnub.min.js"></script>
<!-- Use WebSocket Constructor for a New Socket Connection -->
<script>(function() {
/* 'wss://ORIGIN/PUBLISH_KEY/SUBSCRIBE_KEY/CHANNEL' */
WebSocket = PUBNUB.ws;
var socket = new WebSocket('wss://pubsub.pubnub.com/demo/demo/blockchain_list_blocks')
// On Message Receive
socket.onmessage = function(evt) {
console.log('socket receive');
console.log(evt.data);
}
// On Socket Close
socket.onclose = function() {
console.log('socket closed');
}
// On Error
socket.onerror = function() {
console.log('socket error');
}
// On Connection Establish
socket.onopen = function(evt) {
console.log('socket open');
// Send a Message!
//socket.send('hello world!');
}
// On Send Complete
socket.onsend = function(evt) {
console.log('socket send');
console.log(evt);
}
console.log(socket)
})();</script>