Commit 0c77a962 authored by Taylor Gerring's avatar Taylor Gerring

Move websockets out of cmd/util

parent d92fde69
...@@ -40,6 +40,7 @@ import ( ...@@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/websocket"
"github.com/ethereum/go-ethereum/xeth" "github.com/ethereum/go-ethereum/xeth"
) )
...@@ -200,6 +201,13 @@ func StartRpc(ethereum *eth.Ethereum, RpcPort int) { ...@@ -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 var gminer *miner.Miner
func GetMiner() *miner.Miner { func GetMiner() *miner.Miner {
......
/* /*
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 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 it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
go-ethereum is distributed in the hope that it will be useful, go-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>. along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** package websocket
* @authors
* Jeffrey Wilcke <i@jev.io>
*/
package utils
import ( import (
"github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core"
...@@ -26,15 +22,11 @@ import ( ...@@ -26,15 +22,11 @@ import (
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethutil" "github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event/filter" "github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/state" "github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/ui" "github.com/ethereum/go-ethereum/ui"
"github.com/ethereum/go-ethereum/websocket"
"github.com/ethereum/go-ethereum/xeth" "github.com/ethereum/go-ethereum/xeth"
) )
var wslogger = logger.NewLogger("WS")
func args(v ...interface{}) []interface{} { func args(v ...interface{}) []interface{} {
return v return v
} }
...@@ -54,8 +46,8 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer { ...@@ -54,8 +46,8 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer {
func (self *WebSocketServer) Serv() { func (self *WebSocketServer) Serv() {
pipe := xeth.NewJSXEth(self.eth) pipe := xeth.NewJSXEth(self.eth)
wsServ := websocket.NewServer("/eth", ":40404") wsServ := NewServer("/eth", ":40404")
wsServ.MessageFunc(func(c *websocket.Client, msg *websocket.Message) { wsServ.MessageFunc(func(c *Client, msg *Message) {
switch msg.Call { switch msg.Call {
case "compile": case "compile":
data := ethutil.NewValue(msg.Args) data := ethutil.NewValue(msg.Args)
...@@ -162,13 +154,6 @@ func toMessages(messages state.Messages) (msgs []xeth.JSMessage) { ...@@ -162,13 +154,6 @@ func toMessages(messages state.Messages) (msgs []xeth.JSMessage) {
return 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 // TODO This is starting to become a generic method. Move to utils
func mapToTxParams(object map[string]interface{}) map[string]string { func mapToTxParams(object map[string]interface{}) map[string]string {
// Default values // Default values
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment