websockets accept rpc requests

This commit is contained in:
Jae Kwon
2015-07-23 17:06:38 -07:00
parent 91cf9d4595
commit a84d4320df
13 changed files with 203 additions and 138 deletions

View File

@ -32,17 +32,21 @@ func (wsc *WSClient) Dial() (*http.Response, error) {
// subscribe to an event
func (wsc *WSClient) Subscribe(eventid string) error {
return wsc.conn.WriteJSON(rpctypes.WSRequest{
Type: "subscribe",
Event: eventid,
return wsc.conn.WriteJSON(rpctypes.RPCRequest{
JSONRPC: "2.0",
Id: "",
Method: "subscribe",
Params: []interface{}{eventid},
})
}
// unsubscribe from an event
func (wsc *WSClient) Unsubscribe(eventid string) error {
return wsc.conn.WriteJSON(rpctypes.WSRequest{
Type: "unsubscribe",
Event: eventid,
return wsc.conn.WriteJSON(rpctypes.RPCRequest{
JSONRPC: "2.0",
Id: "",
Method: "unsubscribe",
Params: []interface{}{eventid},
})
}