Skip to content

Commit

Permalink
fix missing xmpp messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ydkn committed May 16, 2019
1 parent 9133cf9 commit 0c84cb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Add sleep of 100ms to XMPP output to ensure message is sent before connection closes

## [0.2.0] - 2019-05-16
### Changed
Expand Down
9 changes: 9 additions & 0 deletions output/xmpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package output

import (
"errors"
"time"

"github.com/mattn/go-xmpp"

Expand Down Expand Up @@ -37,6 +38,7 @@ func XMPP(recipient *recipient.Recipient, event *ExtendedEvent, config *Config)
if err != nil {
return err
}
defer client.Close()

msg, err := resolveTemplate(xmppMessageTemplate, event)
if err != nil {
Expand All @@ -54,6 +56,8 @@ func XMPP(recipient *recipient.Recipient, event *ExtendedEvent, config *Config)
return err
}

time.Sleep(100 * time.Millisecond)

return nil
}

Expand All @@ -77,5 +81,10 @@ func xmppSendMUC(client *xmpp.Client, remote string, msg string) error {
return err
}

_, err = client.LeaveMUC(remote)
if err != nil {
return err
}

return nil
}

0 comments on commit 0c84cb3

Please sign in to comment.