Documentation
¶
Overview ¶
Package client implements the GoSpeak client networking.
Index ¶
- func KeyNameToVK(name string) int
- type Bookmark
- type BookmarkStore
- type ControlClient
- func (c *ControlClient) Authenticate(token, username string) (*pb.AuthResponse, error)
- func (c *ControlClient) Close() error
- func (c *ControlClient) Done() <-chan struct{}
- func (c *ControlClient) Send(msg *pb.ControlMessage) error
- func (c *ControlClient) SetEventHandler(handler EventHandler)
- func (c *ControlClient) StartReceiving()
- type Engine
- func (e *Engine) BanUser(userID int64, reason string, durationSeconds int64) error
- func (e *Engine) Connect(controlAddr, voiceAddr, token, username string) error
- func (e *Engine) CreateChannel(name, description string, maxUsers int) error
- func (e *Engine) CreateChannelAdvanced(name, description string, maxUsers int, parentID int64, isTemp bool, ...) error
- func (e *Engine) CreateSubChannel(parentID int64, name string) error
- func (e *Engine) CreateToken(role string, maxUses int, expiresInSeconds int64) error
- func (e *Engine) DeleteChannel(channelID int64) error
- func (e *Engine) Disconnect()
- func (e *Engine) ExportData(dataType string) error
- func (e *Engine) GetChannels() []pb.ChannelInfo
- func (e *Engine) GetRole() string
- func (e *Engine) GetState() State
- func (e *Engine) GetUsername() string
- func (e *Engine) ImportChannels(yamlData string) error
- func (e *Engine) IsDeafened() bool
- func (e *Engine) IsMuted() bool
- func (e *Engine) JoinChannel(channelID int64) error
- func (e *Engine) KickUser(userID int64, reason string) error
- func (e *Engine) LeaveChannel() error
- func (e *Engine) SendChat(text string) error
- func (e *Engine) SetDeafened(deafened bool)
- func (e *Engine) SetMuted(muted bool)
- func (e *Engine) SetUserRole(targetUserID int64, newRole string) error
- func (e *Engine) SetVADThreshold(threshold float64)
- type EventHandler
- type GlobalHotkeys
- type JitterBuffer
- type Settings
- type State
- type VoiceClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bookmark ¶
type Bookmark struct {
Name string `yaml:"name"`
ControlAddr string `yaml:"control_addr"`
VoiceAddr string `yaml:"voice_addr"`
Username string `yaml:"username"`
Token string `yaml:"token"`
}
Bookmark represents a saved server connection.
type BookmarkStore ¶
type BookmarkStore struct {
Bookmarks []Bookmark `yaml:"bookmarks"`
// contains filtered or unexported fields
}
BookmarkStore manages server bookmarks stored next to the binary.
func NewBookmarkStore ¶
func NewBookmarkStore() *BookmarkStore
NewBookmarkStore creates a bookmark store using a file next to the executable.
func (*BookmarkStore) Add ¶
func (bs *BookmarkStore) Add(b Bookmark) bool
Add adds or updates a bookmark. Returns true if it was a new entry.
func (*BookmarkStore) FindByAddr ¶
func (bs *BookmarkStore) FindByAddr(controlAddr string) *Bookmark
FindByAddr returns a bookmark matching the given control address, or nil.
func (*BookmarkStore) Load ¶
func (bs *BookmarkStore) Load() error
Load reads bookmarks from disk. Returns empty list if file doesn't exist.
type ControlClient ¶
type ControlClient struct {
// contains filtered or unexported fields
}
ControlClient manages the TCP/TLS control plane connection.
func NewControlClient ¶
func NewControlClient(addr string) (*ControlClient, error)
NewControlClient connects to the server's control plane via TLS.
func (*ControlClient) Authenticate ¶
func (c *ControlClient) Authenticate(token, username string) (*pb.AuthResponse, error)
Authenticate sends an auth request and returns the auth response.
func (*ControlClient) Close ¶
func (c *ControlClient) Close() error
Close closes the control connection.
func (*ControlClient) Done ¶
func (c *ControlClient) Done() <-chan struct{}
Done returns a channel that's closed when the connection is lost.
func (*ControlClient) Send ¶
func (c *ControlClient) Send(msg *pb.ControlMessage) error
Send sends a control message to the server.
func (*ControlClient) SetEventHandler ¶
func (c *ControlClient) SetEventHandler(handler EventHandler)
SetEventHandler sets the callback for incoming control messages.
func (*ControlClient) StartReceiving ¶
func (c *ControlClient) StartReceiving()
StartReceiving starts a goroutine that reads incoming control messages and dispatches them to the event handler.
type Engine ¶
type Engine struct {
// Callbacks for UI updates
OnStateChange func(state State)
OnChannelsUpdate func(channels []pb.ChannelInfo)
OnError func(err error)
OnVoiceActivity func(active bool)
OnRMSLevel func(level float64)
OnDisconnect func(reason string)
OnChatMessage func(channelID int64, sender, text string, ts int64)
OnTokenCreated func(token string)
OnRoleChanged func(success bool, message string)
OnAutoToken func(token string) // called when server auto-generates a token for this user
OnExportData func(dataType, data string)
OnImportResult func(success bool, message string)
// contains filtered or unexported fields
}
Engine is the main client engine that wires together audio, networking, and state.
func (*Engine) CreateChannel ¶
CreateChannel sends a create channel request (admin only).
func (*Engine) CreateChannelAdvanced ¶
func (e *Engine) CreateChannelAdvanced(name, description string, maxUsers int, parentID int64, isTemp bool, allowSubChannels bool) error
CreateChannelAdvanced sends a create channel request with all options.
func (*Engine) CreateSubChannel ¶
CreateSubChannel creates a temporary sub-channel under a parent.
func (*Engine) CreateToken ¶
CreateToken sends a create token request (admin only).
func (*Engine) DeleteChannel ¶
DeleteChannel sends a delete channel request (admin only).
func (*Engine) ExportData ¶
ExportData requests the server to export data ("channels" or "users") as YAML.
func (*Engine) GetChannels ¶
func (e *Engine) GetChannels() []pb.ChannelInfo
GetChannels returns the current channel list.
func (*Engine) GetUsername ¶
GetUsername returns the authenticated username.
func (*Engine) ImportChannels ¶
ImportChannels sends a YAML blob for the server to import as channels.
func (*Engine) IsDeafened ¶
IsDeafened returns whether the client is deafened.
func (*Engine) JoinChannel ¶
JoinChannel sends a request to join a channel.
func (*Engine) LeaveChannel ¶
LeaveChannel sends a request to leave the current channel.
func (*Engine) SetDeafened ¶
SetDeafened toggles deafen state.
func (*Engine) SetUserRole ¶
SetUserRole sends a role change request (admin only).
func (*Engine) SetVADThreshold ¶
SetVADThreshold updates the VAD sensitivity.
type EventHandler ¶
type EventHandler func(msg *pb.ControlMessage)
EventHandler is a callback for incoming control events.
type GlobalHotkeys ¶
type GlobalHotkeys struct {
OnMuteToggle func()
OnDeafenToggle func()
}
GlobalHotkeys is a no-op on non-Windows platforms. Users can still use the mute/deafen buttons in the UI.
func NewGlobalHotkeys ¶
func NewGlobalHotkeys() *GlobalHotkeys
NewGlobalHotkeys creates a new GlobalHotkeys instance (no-op on non-Windows).
func (*GlobalHotkeys) SetKeys ¶
func (g *GlobalHotkeys) SetKeys(muteKey, deafenKey string)
SetKeys is a no-op on non-Windows.
type JitterBuffer ¶
type JitterBuffer struct {
// contains filtered or unexported fields
}
JitterBuffer orders incoming voice packets and handles packet loss.
func NewJitterBuffer ¶
func NewJitterBuffer() *JitterBuffer
NewJitterBuffer creates a new jitter buffer.
func (*JitterBuffer) Pop ¶
func (jb *JitterBuffer) Pop() ([]byte, uint32, bool)
Pop returns the next frame in sequence order. Returns (payload, seqNum, ok). If the next frame isn't available, checks if we should skip it (lost packet).
func (*JitterBuffer) Push ¶
func (jb *JitterBuffer) Push(seqNum uint32, payload []byte)
Push adds a packet to the jitter buffer.
type Settings ¶
type Settings struct {
MuteKey string `yaml:"mute_key"`
DeafenKey string `yaml:"deafen_key"`
VADThreshold float64 `yaml:"vad_threshold"`
AudioInput string `yaml:"audio_input,omitempty"`
AudioOutput string `yaml:"audio_output,omitempty"`
}
Settings stores user preferences persisted as YAML next to the binary.
func LoadSettings ¶
func LoadSettings() *Settings
LoadSettings loads settings from YAML or returns defaults.
type VoiceClient ¶
type VoiceClient struct {
// Incoming voice packets are sent here
IncomingPackets chan *protocol.VoicePacket
// contains filtered or unexported fields
}
VoiceClient manages the UDP voice connection.
func NewVoiceClient ¶
func NewVoiceClient(serverAddr string, sessionID uint32, encKey []byte) (*VoiceClient, error)
NewVoiceClient creates a new UDP voice client.
func (*VoiceClient) SendVoice ¶
func (v *VoiceClient) SendVoice(opusData []byte, timestamp uint32) error
SendVoice encrypts and sends an Opus frame over UDP.
func (*VoiceClient) SetChannel ¶
func (v *VoiceClient) SetChannel(channelID int64)
SetChannel sets the current channel ID for outgoing packets.
func (*VoiceClient) StartReceiving ¶
func (v *VoiceClient) StartReceiving()
StartReceiving starts listening for incoming voice packets.