diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-21 03:40:24 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-21 03:40:24 +0800 |
commit | 0c77a962499479cffe7cc5b8e3903197919ca682 (patch) | |
tree | 24aaa1084d916f1754e497d60dd4c00267503b56 | |
parent | d92fde698031758f64fcabe7af354360a93f6326 (diff) | |
download | go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar.gz go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar.bz2 go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar.lz go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar.xz go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.tar.zst go-tangerine-0c77a962499479cffe7cc5b8e3903197919ca682.zip |
Move websockets out of cmd/util
-rw-r--r-- | cmd/utils/cmd.go | 8 | ||||
-rw-r--r-- | websocket/util.go (renamed from cmd/utils/websockets.go) | 43 |
2 files changed, 22 insertions, 29 deletions
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 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 <http://www.gnu.org/licenses/>. + You should have received a copy of the GNU General Public License + along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. */ -/** - * @authors - * Jeffrey Wilcke <i@jev.io> - */ -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 |