diff options
author | xengineering <me@xengineering.eu> | 2023-07-03 20:49:19 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2023-07-03 20:59:55 +0200 |
commit | eca0649c1e0a72fbea4899a295443eac69600bfd (patch) | |
tree | d70d17bc7c62cd53739a76b6386752296cd3658a | |
parent | bde6e0c5095c1fd73058dc8dab408fd5f27aee7c (diff) | |
download | limox-eca0649c1e0a72fbea4899a295443eac69600bfd.tar limox-eca0649c1e0a72fbea4899a295443eac69600bfd.tar.zst limox-eca0649c1e0a72fbea4899a295443eac69600bfd.zip |
Use xml.Encoder.EncodeElement() for presence
This required the trick of defining an empty struct as `presence` type
but works pretty well. For sending data EncodeElement instead of token
handling should always work. Since it is simpler it should be used.
-rw-r--r-- | xmpp/presence.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/xmpp/presence.go b/xmpp/presence.go index b6ea3b5..4adae6e 100644 --- a/xmpp/presence.go +++ b/xmpp/presence.go @@ -5,20 +5,17 @@ import ( "log" ) +type presence struct{} + func (s *session) sendPresence() { start := xml.StartElement{ xml.Name{"", "presence"}, []xml.Attr{}, } - end := start.End() - - tokens := [...]xml.Token{start, end} - for _, v := range tokens { - err := s.ed.encodeToken(v) - if err != nil { - log.Println("Could not encode presence!") - return - } + err := s.ed.tx.EncodeElement(presence{}, start) + if err != nil { + log.Println("Could not encode presence!") + return } } |