Implement server-gererated resource binding.

This commit is contained in:
Matt Goodall 2012-07-09 02:16:25 +01:00
parent 2ab32b0959
commit 3be7cf7b0b
1 changed files with 5 additions and 14 deletions

View File

@ -152,16 +152,13 @@ type saslAuth struct {
}
func bindResource(stream *Stream, jid JID) (JID, error) {
if jid.Resource == "" {
return bindResourceServer(stream)
}
return bindResourceClient(stream, jid)
}
func bindResourceClient(stream *Stream, jid JID) (JID, error) {
req := Iq{Id: "foo", Type: "set"}
req.PayloadEncode(bindIq{Resource: jid.Resource})
if jid.Resource == "" {
req.PayloadEncode(bindIq{})
} else {
req.PayloadEncode(bindIq{Resource: jid.Resource})
}
if err := stream.Send(req); err != nil {
return JID{}, err
}
@ -178,10 +175,6 @@ func bindResourceClient(stream *Stream, jid JID) (JID, error) {
return boundJID, nil
}
func bindResourceServer(stream *Stream) (JID, error) {
panic("bindResourceServer not implemented")
}
type bindIq struct {
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
Resource string `xml:"resource,omitempty"`
@ -230,6 +223,4 @@ type saslFailure struct {
Reason xml.Name `xml:",any"`
}
// BUG(matt): Implement server-side resource binding.
// BUG(matt): Don't use "foo" as the <iq/> id during resource binding.