Allow joining multiple MUCs before sending raw xml messages.

raw
Martin Dosch 3 years ago
parent 866a5d40f3
commit 4d633ef677

@ -395,13 +395,15 @@ func main() {
// Send raw XML to chatroom
if *flagChatroom && *flagRaw {
// Join the MUC.
_, err := client.JoinMUCNoHistory(recipients[0], *flagResource)
if err != nil {
// Try to nicely close connection,
// even if there was an error joining.
_ = client.Close()
log.Fatal(err)
// 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)
@ -411,10 +413,12 @@ func main() {
_ = client.Close()
log.Fatal(err)
}
// After sending the message, leave the Muc
_, err = client.LeaveMUC(recipients[0])
if err != nil {
log.Println(err)
// 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.
@ -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)

Loading…
Cancel
Save