implement Snapshot on Client struct

This commit is contained in:
2026-02-04 11:15:52 +00:00
parent 6f995397a1
commit 66ab937296
3 changed files with 63 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package xair
import (
"fmt"
"net"
"time"
"github.com/charmbracelet/log"
@@ -15,10 +16,11 @@ type parser interface {
type Client struct {
engine
Main *Main
Strip *Strip
Bus *Bus
HeadAmp *HeadAmp
Main *Main
Strip *Strip
Bus *Bus
HeadAmp *HeadAmp
Snapshot *Snapshot
}
// NewClient creates a new XAirClient instance
@@ -85,6 +87,20 @@ func (c *Client) SendMessage(address string, args ...any) error {
return c.engine.sendToAddress(c.mixerAddr, address, args...)
}
// ReceiveMessage receives an OSC message from the mixer
func (c *Client) ReceiveMessage(timeout time.Duration) (*osc.Message, error) {
t := time.Tick(timeout)
select {
case <-t:
return nil, nil
case val := <-c.respChan:
if val == nil {
return nil, fmt.Errorf("no message received")
}
return val, nil
}
}
// RequestInfo requests mixer information
func (c *Client) RequestInfo() (error, InfoResponse) {
err := c.SendMessage("/xinfo")