From 23aeb1fd68a13c4efca409c1ee64b07fe063f4f8 Mon Sep 17 00:00:00 2001 From: Matt Goodall Date: Sun, 8 Jul 2012 12:01:55 +0100 Subject: [PATCH] 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. --- client.go | 4 ++-- component.go | 4 ++-- src/xmpp/client.go | 4 ++-- src/xmpp/component.go | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index 51f7f6c..88912fa 100644 --- a/client.go +++ b/client.go @@ -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 {} } diff --git a/component.go b/component.go index 55034f3..b56391c 100644 --- a/component.go +++ b/component.go @@ -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 {} } diff --git a/src/xmpp/client.go b/src/xmpp/client.go index 38ce43f..3d93e87 100644 --- a/src/xmpp/client.go +++ b/src/xmpp/client.go @@ -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 { diff --git a/src/xmpp/component.go b/src/xmpp/component.go index 895e614..5812024 100644 --- a/src/xmpp/component.go +++ b/src/xmpp/component.go @@ -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) {