Optionally remember transmission state on reconnect.
This commit is contained in:
@@ -81,7 +81,7 @@ func (b *Barnard) connect(reconnect bool) bool {
|
||||
b.toneTestSaverDetach = b.Client.Config.AttachAudio(b.toneTestSaver)
|
||||
|
||||
b.setConnected(true)
|
||||
if b.toneTestAutoTransmit() {
|
||||
if b.shouldStartTransmission() {
|
||||
b.toneTestStop = make(chan struct{})
|
||||
go StartToneGenerator(b.Client, b.toneTestStop)
|
||||
b.setTransmitting(true)
|
||||
@@ -149,7 +149,7 @@ func (b *Barnard) connect(reconnect bool) bool {
|
||||
b.setConnected(true)
|
||||
// Dial delivers OnConnect before connect creates the OpenAL stream, so
|
||||
// start auto-transmit here as well for initial connections and reconnects.
|
||||
b.startAutoTransmit()
|
||||
b.startConfiguredTransmission()
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -195,11 +195,15 @@ func (b *Barnard) OnConnect(e *gumble.ConnectEvent) {
|
||||
b.AddOutputLine(fmt.Sprintf("Welcome message: %s", wmsg))
|
||||
}
|
||||
|
||||
b.startAutoTransmit()
|
||||
b.startConfiguredTransmission()
|
||||
}
|
||||
|
||||
func (b *Barnard) startAutoTransmit() {
|
||||
if !b.AutoTransmit || b.isTransmitting() {
|
||||
func (b *Barnard) shouldStartTransmission() bool {
|
||||
return b.AutoTransmit || (b.UserConfig.GetRememberTransmissionState() && b.UserConfig.GetTransmissionActive())
|
||||
}
|
||||
|
||||
func (b *Barnard) startConfiguredTransmission() {
|
||||
if !b.shouldStartTransmission() || b.isTransmitting() {
|
||||
return
|
||||
}
|
||||
started := b.withStream(func(stream *gumbleopenal.Stream) {
|
||||
@@ -208,8 +212,13 @@ func (b *Barnard) startAutoTransmit() {
|
||||
return
|
||||
}
|
||||
b.setTransmitting(true)
|
||||
b.UpdateGeneralStatus(" AutoTx ", true)
|
||||
b.AddOutputLine("Auto-transmit started")
|
||||
if b.AutoTransmit {
|
||||
b.UpdateGeneralStatus(" AutoTx ", true)
|
||||
b.AddOutputLine("Auto-transmit started")
|
||||
} else {
|
||||
b.UpdateGeneralStatus(" Tx ", true)
|
||||
b.AddOutputLine("Transmission state restored")
|
||||
}
|
||||
})
|
||||
if !started {
|
||||
return
|
||||
@@ -249,7 +258,7 @@ func (b *Barnard) OnDisconnect(e *gumble.DisconnectEvent) {
|
||||
} else {
|
||||
b.AddOutputLine("Disconnected: " + reason)
|
||||
}
|
||||
b.setTransmitting(false)
|
||||
b.clearTransmittingForDisconnect()
|
||||
b.setConnected(false)
|
||||
b.postUI(func() {
|
||||
b.UiTree.Rebuild()
|
||||
|
||||
Reference in New Issue
Block a user