Fix auto transmit and server messages

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 23:28:50 -04:00
committed by Brandon McGinty
parent 219acad951
commit 8348a7083d
2 changed files with 43 additions and 11 deletions
+21 -11
View File
@@ -113,6 +113,9 @@ func (b *Barnard) connect(reconnect bool) bool {
b.FileStreamMutex.Unlock()
b.Connected = true
// Dial delivers OnConnect before connect creates the OpenAL stream, so
// start auto-transmit here as well for initial connections and reconnects.
b.startAutoTransmit()
return true
}
@@ -156,17 +159,20 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", wmsg))
}
// Auto-start transmission if requested
if b.AutoTransmit && b.Stream != nil && !b.Tx {
err := b.Stream.StartSource(b.UserConfig.GetInputDevice())
if err != nil {
b.AddOutputLine(fmt.Sprintf("auto-transmit failed: %s", err.Error()))
} else {
b.Tx = true
b.UpdateGeneralStatus(" AutoTx ", true)
b.AddOutputLine("Auto-transmit started")
}
b.startAutoTransmit()
}
func (b *Barnard) startAutoTransmit() {
if !b.AutoTransmit || b.Stream == nil || b.Tx {
return
}
if err := b.Stream.StartSource(b.UserConfig.GetInputDevice()); err != nil {
b.AddOutputLine(fmt.Sprintf("auto-transmit failed: %s", err.Error()))
return
}
b.Tx = true
b.UpdateGeneralStatus(" AutoTx ", true)
b.AddOutputLine("Auto-transmit started")
}
func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
@@ -232,7 +238,11 @@ func (b *Barnard) OnTextMessage(e *gumble.TextMessageEvent) {
}
}
if public {
b.Notify("msg", e.Sender.Name, e.Message)
sender := "Server"
if e.Sender != nil {
sender = e.Sender.Name
}
b.Notify("msg", sender, e.Message)
b.AddOutputMessage(e.Sender, e.Message)
} else {
var sender string