Documentation
¶
Overview ¶
Package dfhackrpc provides a DFHack RPC client.
Index ¶
- type Client
- func (c *Client) Call(method string, request, response proto.Message) (CommandResult, error)
- func (c *Client) CallPlugin(plugin, method string, request, response proto.Message) (CommandResult, error)
- func (c *Client) Close() error
- func (c *Client) Connect() error
- func (c *Client) ConnectAddr(addr string) error
- func (c *Client) Lock()
- func (c *Client) RunCommand(command string, args ...string) (CommandResult, error)
- func (c *Client) RunLua(module, function string, args ...string) ([]string, CommandResult, error)
- func (c *Client) Unlock()
- type CommandResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a DFHack RPC client. Use NewClient to create an instance of this type. All methods on Client can be called safely from multiple goroutines.
Client will automatically reconnect if a protocol error was encountered on the previous method call.
func NewClient ¶
NewClient constructs a client that writes output to w. The output will use colors if w is a terminal (TTY).
func NewClientColor ¶
NewClientColor constructs a client that writes output to w. The output will use colors if and only if color is set to true.
func (*Client) Call ¶
Call runs an RPC method. It is an error to call a method with the wrong request or response type. If request or response are nil or their types do not match the types used the first time the method was called, Call will panic.
func (*Client) CallPlugin ¶
func (c *Client) CallPlugin(plugin, method string, request, response proto.Message) (CommandResult, error)
CallPlugin runs an RPC method, similar to Call, but also allows you to specify a plugin name in order to call plugin methods API methods.
func (*Client) Close ¶
Close disconnects the client. When this method returns, the client will be in a valid disconnected state regardless of the error returned.
func (*Client) Connect ¶
Connect connects to localhost on the port given by the DFHACK_PORT environment variable, or 5000 if it is not set to a positive integer.
func (*Client) ConnectAddr ¶
ConnectAddr connects to a specified TCP address. If the Client is already connected, an error is returned. If any error occurs while connecting, the client will be in a valid disconnected state when this method returns.
func (*Client) Lock ¶
func (c *Client) Lock()
Lock is a convenience wrapper around the CoreSuspend RPC method. It implements the sync.Locker interface and panics if an error occurs.
func (*Client) RunCommand ¶
func (c *Client) RunCommand(command string, args ...string) (CommandResult, error)
RunCommand is a convenience wrapper around the RunCommand RPC method.
type CommandResult ¶
type CommandResult int
CommandResult is a DFHack command result.
const ( // LinkFailure is a failure due to an I/O or protocol error. LinkFailure CommandResult = -3 // NeedsConsole is a failure due to a command requiring an interactive // context. NeedsConsole CommandResult = -2 // NotImplemented is a failure due to a command not being implemented // or a plugin not being loaded. NotImplemented CommandResult = -1 // OK is success. OK CommandResult = 0 // Failure is a generic failure code. Failure CommandResult = 1 // WrongUsage is a failure due to passing the wrong arguments or using // a command at a time when it is not valid. WrongUsage CommandResult = 2 // NotFound is a failure due to something being missing, usually a // method or command. NotFound CommandResult = 3 )
func (CommandResult) Err ¶
func (rv CommandResult) Err() error
Err is a convenience function that returns an error with the value from rv.String(), or nil if rv is OK.
func (CommandResult) String ¶
func (rv CommandResult) String() string
String implements fmt.Stringer
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
dfhack-run
Command dfhack-run is a port of the dfhack-run command in C++ to Go.
|
Command dfhack-run is a port of the dfhack-run command in C++ to Go. |
Package dfproto contains automatically generated implementations of DFHack protobuf messages.
|
Package dfproto contains automatically generated implementations of DFHack protobuf messages. |
core
Package dfproto_core contains automatically generated implementations of low-level DFHack protobuf messages.
|
Package dfproto_core contains automatically generated implementations of low-level DFHack protobuf messages. |
plugins/isoworldremote
Package isoworldremote contains protocol buffer definitions for the isoworldremote DFHack plugin.
|
Package isoworldremote contains protocol buffer definitions for the isoworldremote DFHack plugin. |
plugins/remotefortressreader
Package remotefortressreader contains protocol buffer definitions for the RemoteFortressReader DFHack plugin.
|
Package remotefortressreader contains protocol buffer definitions for the RemoteFortressReader DFHack plugin. |
plugins/rename
Package rename contains protocol buffer definitions for the rename DFHack plugin.
|
Package rename contains protocol buffer definitions for the rename DFHack plugin. |