mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2025-10-26 06:15:35 -07:00
Added callback to process errors after connection.
Added tests and refactored a bit.
This commit is contained in:
@@ -28,7 +28,7 @@ func main() {
|
||||
router := xmpp.NewRouter()
|
||||
router.HandleFunc("message", handleMessage)
|
||||
|
||||
client, err := xmpp.NewClient(config, router)
|
||||
client, err := xmpp.NewClient(config, router, errorHandler)
|
||||
if err != nil {
|
||||
log.Fatalf("%+v", err)
|
||||
}
|
||||
@@ -39,6 +39,10 @@ func main() {
|
||||
log.Fatal(cm.Run())
|
||||
}
|
||||
|
||||
func errorHandler(err error) {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
func handleMessage(s xmpp.Sender, p stanza.Packet) {
|
||||
msg, ok := p.(stanza.Message)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user