package xmpp import ( "encoding/xml" "fmt" "math/rand" "log" ) type iq struct { XMLName xml.Name `xml:"jabber:client iq"` Type string `xml:"type,attr,omitempty"` 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"` } func (s *session) sendBind() { s.resourceReq = fmt.Sprintf("%016x", rand.Uint64()) req := iq{} req.Id = s.resourceReq req.Type = "set" req.Bind.Resource = "limox-" + fmt.Sprintf("%08x", rand.Uint32()) err := s.tx.Encode(req) if err != nil { log.Println("Could not encode ressource binding!") } } func handleIq(s *session, i iq) { if i.Bind.Jid != "" { s.jid = i.Bind.Jid s.sendPresence() return } }