|
|
|
@ -6,6 +6,7 @@ package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"bufio"
|
|
|
|
|
"context"
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
"errors"
|
|
|
|
|
"fmt"
|
|
|
|
@ -395,7 +396,6 @@ func main() {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
iqc := make(chan xmpp.IQ, defaultBufferSize)
|
|
|
|
|
msgc := make(chan xmpp.Chat, defaultBufferSize)
|
|
|
|
|
go rcvStanzas(client, iqc, msgc)
|
|
|
|
@ -531,15 +531,24 @@ func main() {
|
|
|
|
|
// Quit if ^C is pressed.
|
|
|
|
|
c := make(chan os.Signal, 1)
|
|
|
|
|
signal.Notify(c, os.Interrupt)
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
|
go func() {
|
|
|
|
|
for range c {
|
|
|
|
|
cancel()
|
|
|
|
|
closeAndExit(client, nil)
|
|
|
|
|
}
|
|
|
|
|
}()
|
|
|
|
|
for {
|
|
|
|
|
message, err = reader.ReadString('\n')
|
|
|
|
|
if err != nil {
|
|
|
|
|
closeAndExit(client, errors.New("failed to read from stdin"))
|
|
|
|
|
select {
|
|
|
|
|
case <-ctx.Done():
|
|
|
|
|
return
|
|
|
|
|
default:
|
|
|
|
|
if err != nil {
|
|
|
|
|
closeAndExit(client, errors.New("failed to read from stdin"))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
message = strings.TrimSuffix(message, "\n")
|
|
|
|
|
|
|
|
|
|