1
0
Fork 0

The client and component connections are really just streams too.

Only difference is how they're setup. After that, it's the common iq,
message, presence stuff ... to come soon.
This commit is contained in:
Matt Goodall 2012-07-06 11:19:31 +01:00
parent ad000735ff
commit 627364727e
4 changed files with 8 additions and 18 deletions

View File

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

View File

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

View File

@ -8,11 +8,6 @@ import (
"log"
)
type client struct {
JID JID
stream *Stream
}
// Config structure used to create a new XMPP client connection.
type ClientConfig struct {
// Don't upgrade the connection to TLS, even if the server supports it. If
@ -24,7 +19,7 @@ type ClientConfig struct {
InsecureSkipVerify bool
}
func NewClient(jid JID, password string, config *ClientConfig) (*client, error) {
func ClientStream(jid JID, password string, config *ClientConfig) (*Stream, error) {
stream, err := NewStream(jid.Domain + ":5222")
if err != nil {
@ -64,7 +59,7 @@ func NewClient(jid JID, password string, config *ClientConfig) (*client, error)
break
}
return &client{jid, stream}, nil
return stream, nil
}
func startClient(stream *Stream, jid JID) error {

View File

@ -8,12 +8,7 @@ import (
"log"
)
type component struct {
jid JID
stream *Stream
}
func NewComponent(addr string, jid JID, secret string) (*component, error) {
func ComponentStream(addr string, jid JID, secret string) (*Stream, error) {
stream, err := NewStream(addr)
if err != nil {
@ -29,7 +24,7 @@ func NewComponent(addr string, jid JID, secret string) (*component, error) {
return nil, err
}
return &component{jid, stream}, nil
return stream, nil
}
func startComponent(stream *Stream, jid JID) (string, error) {