Implement server-gererated resource binding.
This commit is contained in:
parent
2ab32b0959
commit
3be7cf7b0b
|
|
@ -152,16 +152,13 @@ type saslAuth struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func bindResource(stream *Stream, jid JID) (JID, error) {
|
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 := 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 {
|
if err := stream.Send(req); err != nil {
|
||||||
return JID{}, err
|
return JID{}, err
|
||||||
}
|
}
|
||||||
|
|
@ -178,10 +175,6 @@ func bindResourceClient(stream *Stream, jid JID) (JID, error) {
|
||||||
return boundJID, nil
|
return boundJID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bindResourceServer(stream *Stream) (JID, error) {
|
|
||||||
panic("bindResourceServer not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
type bindIq struct {
|
type bindIq struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"`
|
||||||
Resource string `xml:"resource,omitempty"`
|
Resource string `xml:"resource,omitempty"`
|
||||||
|
|
@ -230,6 +223,4 @@ type saslFailure struct {
|
||||||
Reason xml.Name `xml:",any"`
|
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.
|
// BUG(matt): Don't use "foo" as the <iq/> id during resource binding.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue