gosc: bitbucket.org/liamstask/gosc Index | Files

package osc

import "bitbucket.org/liamstask/gosc"

gosc provides a pure Go package for sending and receiving OpenSoundControl messages.

Sending messages is a matter of writing a Message to the appropriate io.Writer (net/UDPConn is a common transport), and a simple UDPServer is provided for receiving Messages.

Address pattern matching is also supported.

See the OSC spec at http://opensoundcontrol.org/spec-1_0 for more detail.

Index

Package Files

osc.go pattern.go udpserver.go

func Equal

func Equal(a, b *Message) bool

Equal returns a boolean reporting whether a == b, by comparing the Address and the contents of all Args

func Handle

func Handle(pattern string, h Handler)

func HandleFunc

func HandleFunc(pattern string, handler func(*Message))

func ListenAndServeUDP

func ListenAndServeUDP(addr string, dispatcher Dispatcher) error

func PatternMatch

func PatternMatch(pattern, test string) bool

Determines whether pattern (typically the Address of an incoming Message) matches test (typically the Address of a registered handler).

Pattern matching semantics are described in the OSC spec (http://opensoundcontrol.org/spec-1_0) in the section entitled "OSC Message Dispatching and Pattern Matching".

type Bundle

type Bundle struct {
    Timetag  time.Time
    Messages []*Message
}

A collection of OSC Messages. It's often more efficient to send multiple messages as a Bundle as they can all be included in the same transmission to the receiver.

func ReadFrom

func ReadFrom(r io.Reader) (bndl *Bundle, err error)

ReadFrom retrieves a Bundle from the given io.Reader. In the event that the incoming packet is a single message, the returned Bundle will contain a single Message with its Timetag set to 'immediate'

func (*Bundle) WriteTo

func (b *Bundle) WriteTo(w io.Writer) (n int, err error)

WriteTo writes b to w.

type Dispatcher

type Dispatcher interface {
    Dispatch(*Bundle)
}

type Handler

type Handler interface {
    HandleOSC(*Message)
}

type HandlerFunc

type HandlerFunc func(*Message)

func (HandlerFunc) HandleOSC

func (f HandlerFunc) HandleOSC(m *Message)

type Message

type Message struct {
    Address string
    Args    []interface{}
}

A single OSC message. Args is a slice of arguments, each of which may be one of the following types: int32, float32, string, bool, nil, or []byte (ie, an OSC 'blob')

func (*Message) WriteTo

func (m *Message) WriteTo(w io.Writer) (n int, err error)

WriteTo writes m to w.

type ServeMux

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

func NewServeMux

func NewServeMux() *ServeMux

func (*ServeMux) Dispatch

func (mux *ServeMux) Dispatch(b *Bundle)

func (*ServeMux) Handle

func (mux *ServeMux) Handle(pattern string, handler Handler)

type UDPServer

type UDPServer struct {
    Address     string        // UDP address to listen on
    Dispatcher  Dispatcher    // Dispatcher to invoke, osc.defaultServeMux if nil
    ReadTimeout time.Duration // maximum duration before timing out read of the request
}

func (*UDPServer) ListenAndServe

func (s *UDPServer) ListenAndServe() error

Package osc imports 9 packages (graph) and is imported by 1 packages. Updated 2014-03-22. Refresh now. Tools for package owners.