Documentation
¶
Overview ¶
Package intiface provides a manager for the Intiface CLI.
Example ¶
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) defer cancel() ws := NewWebsocket(0, intifaceCLI) ch := ws.Open(ctx) for ev := range ch { switch ev := ev.(type) { case *buttplug.InternalError: log.Println("error:", ev.Err) case *buttplug.ServerInfo: log.Printf("server %q, version %d.%d", ev.ServerName, ev.MajorVersion, ev.MinorVersion) // Try pinging synchronously. v, err := ws.Command(ctx, &buttplug.RequestDeviceList{}) if err != nil { log.Fatalln("cannot request device list:", err) } devices := v.(*buttplug.DeviceList) log.Println("devices:", devices) // Exit. cancel() } } if err := ws.LastError(); err != nil { log.Fatalln("error:", err) }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var EnableConsole = false
EnableConsole, if true, will make the Intiface CLI print to stderr.
Functions ¶
Types ¶
type CLIHandler ¶
type CLIHandler interface { // OnConnect is called everytime the IntifaceCLI is started. The caller // should use this method to start the connection and optionally block until // the connection dies. OnConnect(address string) bool // Log logs the given error. Log(err error) // Close closes the handler. Close() }
CLIHandler describes the handler that the Intiface CLI manager accepts.
type Websocket ¶
type Websocket struct { *buttplug.Websocket // contains filtered or unexported fields }
Websocket wraps around a Buttplug Websocket to simultaneously manage the CLI in the background.
func NewWebsocket ¶
NewWebsocket creates a new websocket instance. If port is 0, then the default port is 20000.
Click to show internal directories.
Click to hide internal directories.