aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/ws
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-01-29 00:22:37 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-01-29 00:22:37 +0800
commita88f609b8ab1e20eb2564d47605985d6b8f593e8 (patch)
tree330811da2775b2e186f1927886840eb275ecc628 /rpc/ws
parente9d017ba082bfd624267c974fa93a77da6269756 (diff)
downloadgo-tangerine-a88f609b8ab1e20eb2564d47605985d6b8f593e8.tar.gz
go-tangerine-a88f609b8ab1e20eb2564d47605985d6b8f593e8.tar.zst
go-tangerine-a88f609b8ab1e20eb2564d47605985d6b8f593e8.zip
Use custom Send methods
Diffstat (limited to 'rpc/ws')
-rw-r--r--rpc/ws/server.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/rpc/ws/server.go b/rpc/ws/server.go
index 248ebc585..e2b918430 100644
--- a/rpc/ws/server.go
+++ b/rpc/ws/server.go
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
-package ws
+package rpcws
import (
"fmt"
@@ -30,6 +30,7 @@ import (
)
var wslogger = logger.NewLogger("RPC-WS")
+var JSON rpc.JsonWrapper
type WebSocketServer struct {
eth *eth.Ethereum
@@ -98,25 +99,28 @@ func (s *WebSocketServer) apiHandler(api *rpc.EthereumApi) http.Handler {
func sockHandler(api *rpc.EthereumApi) websocket.Handler {
fn := func(conn *websocket.Conn) {
for {
- wslogger.Debugln("Handling request")
+ wslogger.Debugln("Handling connection")
var reqParsed rpc.RpcRequest
+ // reqParsed, reqerr := JSON.ParseRequestBody(conn.Request())
if err := websocket.JSON.Receive(conn, &reqParsed); err != nil {
- wslogger.Debugln(rpc.ErrorParseRequest)
- websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: rpc.ErrorParseRequest})
+ // if reqerr != nil {
+ JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: rpc.ErrorParseRequest})
+ // websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: rpc.ErrorParseRequest})
continue
}
var response interface{}
reserr := api.GetRequestReply(&reqParsed, &response)
if reserr != nil {
- wslogger.Errorln(reserr)
- websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})
+ // websocket.JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})
+ JSON.Send(conn, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})
continue
}
wslogger.Debugf("Generated response: %T %s", response, response)
- websocket.JSON.Send(conn, rpc.RpcSuccessResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: false, Result: response})
+ JSON.Send(conn, &rpc.RpcSuccessResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: false, Result: response})
+ // websocket.JSON.Send(conn, rpc.RpcSuccessResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: false, Result: response})
}
}
return websocket.Handler(fn)