ipc

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: EUPL-1.2 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoXLRSocket      = "/tmp/goxlr.socket"
	GetStatusCommand = `"GetStatus"`
)

Variables

This section is empty.

Functions

func DialSocket

func DialSocket(ctx context.Context) (net.Conn, error)

DialSocket dials the GoXLR socket.

func MustGetAddress

func MustGetAddress(ctx context.Context) string

MustGetAddress returns the address the HTTP API is bound on.

This function will panic if any error occurs, or if the HTTP API is not enabled.

func PackRequest

func PackRequest(msg json.RawMessage) ([]byte, error)

PackRequest will take any string payload and encoded it in the format the daemon expects.

The msg should be valid JSON and be one of the supported commands.

func UnpackResponse

func UnpackResponse(r io.Reader) (json.RawMessage, error)

UnpackResponse will read a response from the Reader.

Beware that this can hang indefinitely if you pass a net.Conn and the command you sent is unknown to the daemon. It won't respond with an error message, it simply doesn't respond at all. Make sure to manage the net.Conn.ReadDeadline so that a read will eventually time out.

Types

type DaemonStatus

type DaemonStatus struct {
	Status struct {
		Config struct {
			HTTPSettings struct {
				Enabled     bool   `json:"enabled"`
				BindAddress string `json:"bind_address"`
				Port        int    `json:"port"`
			} `json:"http_settings"`
		} `json:"config"`
	} `json:"Status"`
}

DaemonStatus is a partial struct representing the data returned by the GetStatus command.

It only represents the part of the response necessary to construct the HTTP API address.

func (DaemonStatus) GetAddress

func (d DaemonStatus) GetAddress() (string, bool)

GetAddress returns a host:port for the HTTP API.

If the HTTP API is not enabled, the second return value will be false.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL