diff options
-rw-r--r-- | xmpp/iq.go | 28 |
1 files changed, 6 insertions, 22 deletions
@@ -13,35 +13,19 @@ type iq struct { Id string `xml:"id,attr,omitempty"` Bind struct{ Jid string `xml:"jid,omitempty"` + Resource string `xml:"resource,omitempty"` } `xml:"urn:ietf:params:xml:ns:xmpp-bind bind,omitempty"` } -type bindRequest struct { - Bind struct { - Xmlns string `xml:"xmlns,attr"` - Resource struct { - Content string `xml:",chardata"` - } `xml:"resource"` - } `xml:"bind"` -} - func (s *session) sendBind() { - s.resourceReq = fmt.Sprintf("%016x", rand.Uint64()) - start := xml.StartElement{ - xml.Name{"jabber:client", "iq"}, - []xml.Attr{ - xml.Attr{xml.Name{"", "id"}, s.resourceReq}, - xml.Attr{xml.Name{"", "type"}, "set"}, - }, - } - - inner := bindRequest{} - inner.Bind.Xmlns = "urn:ietf:params:xml:ns:xmpp-bind" - inner.Bind.Resource.Content = "limox-" + fmt.Sprintf("%08x", rand.Uint32()) + req := iq{} + req.Id = s.resourceReq + req.Type = "set" + req.Bind.Resource = "limox-" + fmt.Sprintf("%08x", rand.Uint32()) - err := s.tx.EncodeElement(inner, start) + err := s.tx.Encode(req) if err != nil { log.Println("Could not encode ressource binding!") } |