From 35e9e8742843b7bcc695b162e8d1e530bbb0d3a3 Mon Sep 17 00:00:00 2001 From: Martin Boehm Date: Wed, 21 Feb 2018 20:24:50 +0100 Subject: [PATCH] Use forked golang-socketio library to handle subscribe messages --- docker/Dockerfile | 2 +- server/socketio.go | 8 +++---- server/static/test.html | 46 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 681ee320..3502204e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -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 diff --git a/server/socketio.go b/server/socketio.go index 11bdb325..4827bf4a 100644 --- a/server/socketio.go +++ b/server/socketio.go @@ -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 } diff --git a/server/static/test.html b/server/static/test.html index 4ff3a6e6..02921168 100644 --- a/server/static/test.html +++ b/server/static/test.html @@ -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); + }); + } @@ -295,6 +318,29 @@
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+