diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go index a57d3266f..95a7f89c8 100644 --- a/cmd/utils/cmd.go +++ b/cmd/utils/cmd.go @@ -40,6 +40,7 @@ import ( "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/state" + "github.com/ethereum/go-ethereum/websocket" "github.com/ethereum/go-ethereum/xeth" ) @@ -200,6 +201,13 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) { } } +func StartWebSockets(eth *eth.Ethereum) { + clilogger.Infoln("Starting WebSockets") + + sock := websocket.NewWebSocketServer(eth) + go sock.Serv() +} + var gminer *miner.Miner func GetMiner() *miner.Miner { diff --git a/cmd/utils/websockets.go b/websocket/util.go similarity index 79% rename from cmd/utils/websockets.go rename to websocket/util.go index 48ea4014b..943032b06 100644 --- a/cmd/utils/websockets.go +++ b/websocket/util.go @@ -1,24 +1,20 @@ /* - This file is part of go-ethereum + This file is part of go-ethereum - go-ethereum is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. + go-ethereum is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. - go-ethereum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + go-ethereum is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with go-ethereum. If not, see . + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see . */ -/** - * @authors - * Jeffrey Wilcke - */ -package utils +package websocket import ( "github.com/ethereum/go-ethereum/core" @@ -26,15 +22,11 @@ import ( "github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/event/filter" - "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/ui" - "github.com/ethereum/go-ethereum/websocket" "github.com/ethereum/go-ethereum/xeth" ) -var wslogger = logger.NewLogger("WS") - func args(v ...interface{}) []interface{} { return v } @@ -54,8 +46,8 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer { func (self *WebSocketServer) Serv() { pipe := xeth.NewJSXEth(self.eth) - wsServ := websocket.NewServer("/eth", ":40404") - wsServ.MessageFunc(func(c *websocket.Client, msg *websocket.Message) { + wsServ := NewServer("/eth", ":40404") + wsServ.MessageFunc(func(c *Client, msg *Message) { switch msg.Call { case "compile": data := ethutil.NewValue(msg.Args) @@ -162,13 +154,6 @@ func toMessages(messages state.Messages) (msgs []xeth.JSMessage) { return } -func StartWebSockets(eth *eth.Ethereum) { - wslogger.Infoln("Starting WebSockets") - - sock := NewWebSocketServer(eth) - go sock.Serv() -} - // TODO This is starting to become a generic method. Move to utils func mapToTxParams(object map[string]interface{}) map[string]string { // Default values