Documentation ¶
Index ¶
- Constants
- Variables
- func AddHandler(s PigServer, command string, handler func(*goosc.Message) ([]string, error))
- func BatchLoad(filename string) error
- func Cleanup()
- func Eval(command string, args []string)
- func Init()
- func Listen()
- func Prompt()
- func REPL()
- func Read() string
- type BasicResponder
- type OSCServer
- func (s *OSCServer) AddMsgHandler(address string, handler func(msg *goosc.Message))
- func (s *OSCServer) Close()
- func (s *OSCServer) Commands() []string
- func (s *OSCServer) GetREPLResponder() Responder
- func (s *OSCServer) GetResponder() Responder
- func (s *OSCServer) IP() string
- func (s *OSCServer) ListenAndServe()
- func (s *OSCServer) Port() int
- func (s *OSCServer) Root() string
- func (s *OSCServer) SetRoot(root string)
- type PigServer
- type REPLResponder
- type Responder
Constants ¶
const (
COMMENT = "#"
)
Variables ¶
var ( GlobalServer PigServer Exit bool = false // Flag to main-loop, if true exit application. )
Functions ¶
func AddHandler ¶
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 ¶
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.
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 (*OSCServer) GetREPLResponder ¶
func (*OSCServer) GetResponder ¶
func (*OSCServer) ListenAndServe ¶
func (s *OSCServer) ListenAndServe()
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.
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 ¶
NewBasicResponder() creates a new instance of basicResponder.
func NewREPLResponder ¶
func NewREPLResponder() Responder
NewREPLResponder() creates new instance of REPLResponder.