|
|
|
@ -395,14 +395,16 @@ func main() {
|
|
|
|
|
// Send raw XML to chatroom
|
|
|
|
|
if *flagChatroom && *flagRaw {
|
|
|
|
|
|
|
|
|
|
// Join the MUC.
|
|
|
|
|
_, err := client.JoinMUCNoHistory(recipients[0], *flagResource)
|
|
|
|
|
// Join the MUCs.
|
|
|
|
|
for _, recipient := range recipients {
|
|
|
|
|
_, err := client.JoinMUCNoHistory(recipient, *flagResource)
|
|
|
|
|
if err != nil {
|
|
|
|
|
// Try to nicely close connection,
|
|
|
|
|
// even if there was an error joining.
|
|
|
|
|
_ = client.Close()
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Send raw XMP
|
|
|
|
|
_, err = client.SendOrg(message)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -411,11 +413,13 @@ func main() {
|
|
|
|
|
_ = client.Close()
|
|
|
|
|
log.Fatal(err)
|
|
|
|
|
}
|
|
|
|
|
// After sending the message, leave the Muc
|
|
|
|
|
// After sending the message, leave the MUCs
|
|
|
|
|
for _, recipient := range recipients {
|
|
|
|
|
_, err = client.LeaveMUC(recipients[0])
|
|
|
|
|
if err != nil {
|
|
|
|
|
log.Println(err)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Wait for a short time as some messages are not delievered by the server
|
|
|
|
|
// if the connection is closed immediately after sending a message.
|
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
@ -481,8 +485,6 @@ func main() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// If the chatroom flag is not set, send message to contact(s).
|
|
|
|
|
|
|
|
|
|
// Send raw XML
|
|
|
|
|
if *flagRaw {
|
|
|
|
|
_, err = client.SendOrg(message)
|
|
|
|
|