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) jid, _ := xmpp.ParseJID(*jid)
password := *password password := *password
stream, err := xmpp.NewClientStream(jid, password, &xmpp.ClientConfig{}) x, err := xmpp.NewClientXMPP(jid, password, &xmpp.ClientConfig{})
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
x.Send(xmpp.Presence{})
log.Println(stream)
select {} select {}
} }

View File

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

View File

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

View File

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