Documentation ¶
Index ¶
- type RPCClient
- func (client *RPCClient) Close()
- func (client *RPCClient) ConnectionStatus() rpc.Status
- func (client *RPCClient) IsClosed() bool
- func (client *RPCClient) Method(success func([]byte) error, setupAndTeardown func() func(error), method string, ...)
- func (client *RPCClient) MethodSync(response interface{}, method string, params ...interface{}) error
- func (client *RPCClient) OnConnect(callback func() error)
- func (client *RPCClient) RegisterHeartbeat(method string, params ...interface{})
- func (client *RPCClient) RegisterOnConnectionStatusChangedEvent(onConnectionStatusChangedEvent func(rpc.Status))
- func (client *RPCClient) SubscribeNotifications(method string, callback func([]byte))
- type ResponseError
- type SocketError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RPCClient ¶
type RPCClient struct {
// contains filtered or unexported fields
}
RPCClient is a generic json rpc client, which is able to invoke remote methods and subscribe to remote notifications.
func NewRPCClient ¶
NewRPCClient creates a new RPCClient. conn is used for transport (e.g. a tcp/tls connection).
func (*RPCClient) ConnectionStatus ¶
ConnectionStatus returns the current connection status of this client to the backend(s).
func (*RPCClient) Method ¶
func (client *RPCClient) Method( success func([]byte) error, setupAndTeardown func() func(error), method string, params ...interface{}, )
Method sends invokes the remote method with the provided parameters. Before the request is send, the setupAndTeardown callback is executed and the return value is stored as cleanup callback with the pending request. The success callback is called with the response. cleanup is called afterwards.
func (*RPCClient) MethodSync ¶
func (client *RPCClient) MethodSync(response interface{}, method string, params ...interface{}) error
MethodSync is the same as method, but blocks until the response is available. The result is json-deserialized into response.
func (*RPCClient) OnConnect ¶
OnConnect executed the given callback whenever a new connection is established
func (*RPCClient) RegisterHeartbeat ¶
RegisterHeartbeat registers the heartbeat method and parameters that are sent to the backend to keep the connection alive
func (*RPCClient) RegisterOnConnectionStatusChangedEvent ¶
func (client *RPCClient) RegisterOnConnectionStatusChangedEvent(onConnectionStatusChangedEvent func(rpc.Status))
RegisterOnConnectionStatusChangedEvent registers an event that is fired if the connection status changes. After registration it fires the event to notify the holder of the callback about the current status. TODO: eventually return a de-register method that deletes the callback. Will be required once we allow the user to manage their accounts fully.
func (*RPCClient) SubscribeNotifications ¶
SubscribeNotifications installs a callback for a method which is called with notifications from the server.
type ResponseError ¶
type ResponseError struct {
// contains filtered or unexported fields
}
ResponseError indicates an error when parsing the response from the server.
func (*ResponseError) Error ¶
func (err *ResponseError) Error() string
type SocketError ¶
type SocketError struct {
// contains filtered or unexported fields
}
SocketError indicates an error when reading from or writing to a network socket.
func (*SocketError) Error ¶
func (err *SocketError) Error() string