osc

package
v0.0.0-...-df27725 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMMENT = "#"
)

Variables

View Source
var (
	GlobalServer PigServer

	Exit bool = false // Flag to main-loop, if true exit application.
)

Functions

func AddHandler

func AddHandler(s PigServer, command string, handler func(*goosc.Message) ([]string, error))

AddHandler() adds new OSC handler function to server s. The OSC address prefix is automatically added to the command argument. The command "foo" --> becomes "/pig/foo"

func BatchLoad

func BatchLoad(filename string) error

BatchLoad() loads batch file. A batch file is a sequence of osc commands with identical syntax to interactive commands. Lines beginning with # are ignored.

The filename argument may begin with the special characters:

~/  file is relative to the user's home directory.
!/  file is relative to the configuration directory.

Returns non-nil error if the file could not be read.

func Cleanup

func Cleanup()

Cleanup() closes OSC server. Cleanup should only be called on application termination.

func Eval

func Eval(command string, args []string)

Eval() evaluates REPL commands.

func Init

func Init()

Init() initializes the osc package. Init() must not be called prior to initialization of the config package.

func Listen

func Listen()

Listen() starts OSC server.

func Prompt

func Prompt()

Prompt() displays terminal prompt.

func REPL

func REPL()

REPL() enters the interactive command loop.

func Read

func Read() string

Types

type BasicResponder

type BasicResponder struct {
	// contains filtered or unexported fields
}

BasciResponder is the primary implementation of the Responder interface. In addition to transmitting ACk and Error responses, it also writes identical information to a temporary file. This is useful for clients which do not receive OSC. The file is overwritten each time a new OSC message is received.

func (*BasicResponder) Ack

func (r *BasicResponder) Ack(sourceAddress string, args []string)

f.Ack() transmits an Acknowledgment response to the client.

func (*BasicResponder) Error

func (r *BasicResponder) Error(sourceAddress string, args []string, err error)

f.Error() transmits an Error response to the client.

func (*BasicResponder) String

func (r *BasicResponder) String() string

type OSCServer

type OSCServer struct {
	// contains filtered or unexported fields
}

OSCServer struct implements the PigServer interface.

func (*OSCServer) AddMsgHandler

func (s *OSCServer) AddMsgHandler(address string, handler func(msg *goosc.Message))

func (*OSCServer) Close

func (s *OSCServer) Close()

func (*OSCServer) Commands

func (s *OSCServer) Commands() []string

func (*OSCServer) GetREPLResponder

func (s *OSCServer) GetREPLResponder() Responder

func (*OSCServer) GetResponder

func (s *OSCServer) GetResponder() Responder

func (*OSCServer) IP

func (s *OSCServer) IP() string

func (*OSCServer) ListenAndServe

func (s *OSCServer) ListenAndServe()

func (*OSCServer) Port

func (s *OSCServer) Port() int

func (*OSCServer) Root

func (s *OSCServer) Root() string

func (*OSCServer) SetRoot

func (s *OSCServer) SetRoot(root string)

type PigServer

type PigServer interface {
	Root() string
	SetRoot(string)
	GetResponder() Responder
	GetREPLResponder() Responder
	AddMsgHandler(address string, handler func(msg *goosc.Message))
	ListenAndServe()
	IP() string
	Port() int
	Close()
	Commands() []string
}

PigServer interface defines server-side OSC interface.

Root() string

Returns the OSC address prefix, default is '/pig'

SetRoot(s string)

Sets OSC server address prefix.

GetResponder() Responder

Returns the OSC responder.

GetREPLResponder() Responder

Returns the responder used for printing to the terminal.

AddMsgHandler(address string, handler func(msg *go-osc.Message))

Adds an OSC handler function.

ListenAndServe()

Start server.

IP() string

Returns server IP address.

Port() int

Returns server port number.

Close()

Close the server.  Close should only be called on termination of the
program.

Commands() []string

Returns list of defined OSC commands.

func NewServer

func NewServer(ip string, port int, root string) PigServer

NewServer() returns a new PigServer.

type REPLResponder

type REPLResponder struct{}

REPLResponder struct is a Responder which prints messages to the terminal.

func (*REPLResponder) Ack

func (r *REPLResponder) Ack(sourceAddress string, args []string)

func (*REPLResponder) Error

func (r *REPLResponder) Error(sourceAddress string, args []string, err error)

func (*REPLResponder) String

func (r *REPLResponder) String() string

type Responder

type Responder interface {
	Ack(sourceAddress string, args []string)
	Error(sourceAddress string, args []string, err error)
	String() string
}

Responder interface defines how the OSC server sends responses back to the client.

There are two possible responses: Ack and Error.

Ack() sends an Acknowledgment that an OSC message has been received without error. As part of its "payload" it includes the original message and any requested data.

An Error() response indicates the last received OSC message caused an error. The response includes the offending OSC message and an additional error message.

func NewBasicResponder

func NewBasicResponder(ip string, port int, root string, filename string) Responder

NewBasicResponder() creates a new instance of basicResponder.

func NewREPLResponder

func NewREPLResponder() Responder

NewREPLResponder() creates new instance of REPLResponder.

Jump to

Keyboard shortcuts

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