Associate a JID with an XMPP instance.

Client connections negotiate a bound resource JID with the server. The
bound JID may be different from the one requested or even generated by
the server.

Component connections do not negotiate the bound JID but still have a
specific JID associated with the stream.
This commit is contained in:
Matt Goodall 2012-07-08 12:01:55 +01:00
parent 1836b6bf2d
commit 23aeb1fd68
4 changed files with 9 additions and 9 deletions

View File

@ -17,11 +17,11 @@ func main() {
jid, _ := xmpp.ParseJID(*jid)
password := *password
stream, err := xmpp.NewClientStream(jid, password, &xmpp.ClientConfig{})
x, err := xmpp.NewClientXMPP(jid, password, &xmpp.ClientConfig{})
if err != nil {
log.Fatal(err)
}
x.Send(xmpp.Presence{})
log.Println(stream)
select {}
}

View File

@ -16,11 +16,11 @@ func main() {
jid, _ := xmpp.ParseJID(*jid)
secret := *secret
stream, err := xmpp.NewComponentStream("localhost:5347", jid, secret)
x, err := xmpp.NewComponentXMPP("localhost:5347", jid, secret)
if err != nil {
log.Fatal(err)
}
log.Println(stream)
log.Println(x)
select {}
}

View File

@ -20,7 +20,7 @@ type ClientConfig struct {
}
// Create a client XMPP stream.
func NewClientStream(jid JID, password string, config *ClientConfig) (*Stream, error) {
func NewClientXMPP(jid JID, password string, config *ClientConfig) (*XMPP, error) {
stream, err := NewStream(jid.Domain + ":5222")
if err != nil {
@ -60,7 +60,7 @@ func NewClientStream(jid JID, password string, config *ClientConfig) (*Stream, e
break
}
return stream, nil
return newXMPP(jid, stream), nil
}
func startClient(stream *Stream, jid JID) error {

View File

@ -8,8 +8,8 @@ import (
"log"
)
// Create a component XMPP stream.
func NewComponentStream(addr string, jid JID, secret string) (*Stream, error) {
// Create a component XMPP connection.
func NewComponentXMPP(addr string, jid JID, secret string) (*XMPP, error) {
stream, err := NewStream(addr)
if err != nil {
@ -25,7 +25,7 @@ func NewComponentStream(addr string, jid JID, secret string) (*Stream, error) {
return nil, err
}
return stream, nil
return newXMPP(jid, stream), nil
}
func startComponent(stream *Stream, jid JID) (string, error) {