Properly quit connection in interactive mode.

v0.6
Martin Dosch 11 months ago
parent 48d50b5667
commit b0e67b7ff0
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D

@ -1,6 +1,8 @@
# Changelog
## Unreleased
### Changed
- Properly close connection to server if ^C is pressed in interactive mode.
## [v0.6.1] 2023-07-25
### Changed

@ -13,6 +13,7 @@ import (
"log"
"net"
"os"
"os/signal"
"strings"
"time"
@ -314,7 +315,6 @@ func main() {
iqc := make(chan xmpp.IQ, defaultBufferSize)
msgc := make(chan xmpp.Chat, defaultBufferSize)
go rcvStanzas(client, iqc, msgc)
for _, r := range getopt.Args() {
var re recipientsType
re.Jid = r
@ -441,6 +441,15 @@ func main() {
case *flagInteractive:
// Send in endless loop (for usage with e.g. "tail -f").
reader := bufio.NewReader(os.Stdin)
// Quit if ^C is pressed.
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for range c {
client.Close()
os.Exit(0)
}
}()
for {
message, err = reader.ReadString('\n')
message = strings.TrimSuffix(message, "\n")

Loading…
Cancel
Save