Use forked golang-socketio library to handle subscribe messages
This commit is contained in:
parent
395e69143d
commit
35e9e87428
@ -23,7 +23,7 @@ RUN cd /opt/rocksdb && CFLAGS=-fPIC CXXFLAGS=-fPIC make static_lib
|
||||
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy -llz4" go get github.com/tecbot/gorocksdb
|
||||
|
||||
RUN go get github.com/golang/glog
|
||||
RUN go get github.com/graarh/golang-socketio
|
||||
RUN go get github.com/martinboehm/golang-socketio
|
||||
RUN go get github.com/btcsuite/btcd
|
||||
RUN go get github.com/gorilla/handlers
|
||||
RUN go get github.com/bsm/go-vlq
|
||||
|
||||
@ -11,8 +11,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/graarh/golang-socketio"
|
||||
"github.com/graarh/golang-socketio/transport"
|
||||
"github.com/martinboehm/golang-socketio"
|
||||
"github.com/martinboehm/golang-socketio/transport"
|
||||
)
|
||||
|
||||
// SocketIoServer is handle to SocketIoServer
|
||||
@ -634,7 +634,7 @@ func (s *SocketIoServer) sendTransaction(tx string) (res resultSendTransaction,
|
||||
return
|
||||
}
|
||||
|
||||
func (s *SocketIoServer) onSubscribe(c *gosocketio.Channel, req json.RawMessage) interface{} {
|
||||
glog.Info(c.Id(), " onSubscribe ", req)
|
||||
func (s *SocketIoServer) onSubscribe(c *gosocketio.Channel, req []byte) interface{} {
|
||||
glog.Info(c.Id(), " onSubscribe ", string(req))
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -179,6 +179,29 @@
|
||||
];
|
||||
return socket.send({ method, params }, f);
|
||||
}
|
||||
|
||||
function subscribeHashBlock() {
|
||||
socket.emit('subscribe', "bitcoind/hashblock", function (result) {
|
||||
console.log('subscribe bitcoind/hashblock sent successfully');
|
||||
console.log(result);
|
||||
});
|
||||
socket.on("bitcoind/hashblock", function (result) {
|
||||
console.log('on bitcoind/hashblock');
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
|
||||
function subscribeAddressTxid() {
|
||||
var addresses = document.getElementById('subscribeAddressTxidAddresses').value.split(",");
|
||||
socket.emit('subscribe', "bitcoind/addresstxid", addresses, function (result) {
|
||||
console.log('subscribe bitcoind/addresstxid sent successfully');
|
||||
console.log(result);
|
||||
});
|
||||
socket.on("bitcoind/addresstxid", function (result) {
|
||||
console.log('on bitcoind/addresstxid');
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
@ -295,6 +318,29 @@
|
||||
<div class="col" id="sendTransactionResult">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input class="btn btn-secondary" type="button" value="subscribe hashblock" onclick="subscribeHashBlock()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" id="subscribeHashBlockResult">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<input class="btn btn-secondary" type="button" value="subscribe addresstxid" onclick="subscribeAddressTxid()">
|
||||
</div>
|
||||
<div class="col-8">
|
||||
<input type="text" class="form-control" id="subscribeAddressTxidAddresses" value="2MzTmvPJLZaLzD9XdN3jMtQA5NexC3rAPww,2NAZRJKr63tSdcTxTN3WaE9ZNDyXy6PgGuv">
|
||||
</div>
|
||||
<div class="col">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col" id="subscribeAddressTxidResult">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user