diff options
Diffstat (limited to 'websocket')
-rw-r--r-- | websocket/client.go | 8 | ||||
-rw-r--r-- | websocket/message.go | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/websocket/client.go b/websocket/client.go index db2c8e5c9..340a67aea 100644 --- a/websocket/client.go +++ b/websocket/client.go @@ -51,7 +51,13 @@ func (c *Client) Conn() *ws.Conn { } func (c *Client) Write(data interface{}, id int) { - msg := &Message{Id: id, Data: data} + c.write(&Message{Id: id, Data: data}) +} +func (c *Client) Event(data interface{}, ev string, id int) { + c.write(&Message{Id: id, Data: data, Event: ev}) +} + +func (c *Client) write(msg *Message) { select { case c.ch <- msg: default: diff --git a/websocket/message.go b/websocket/message.go index 73b47456f..cd2af5099 100644 --- a/websocket/message.go +++ b/websocket/message.go @@ -3,10 +3,11 @@ package websocket import "github.com/ethereum/go-ethereum/ethutil" type Message struct { - Call string `json:"call"` - Args []interface{} `json:"args"` - Id int `json:"_id"` - Data interface{} `json:"data"` + Call string `json:"call"` + Args []interface{} `json:"args"` + Id int `json:"_id"` + Data interface{} `json:"data"` + Event string `json:"_event"` } func (self *Message) Arguments() *ethutil.Value { |