forked from jshiffer/go-xmpp
fix parsing xml.
This commit is contained in:
parent
f482858a52
commit
f8ce0ead60
38
xmpp.go
38
xmpp.go
@ -119,7 +119,7 @@ func (c *Client) Close() error {
|
|||||||
|
|
||||||
func (c *Client) init(user, passwd string) error {
|
func (c *Client) init(user, passwd string) error {
|
||||||
// For debugging: the following causes the plaintext of the connection to be duplicated to stdout.
|
// For debugging: the following causes the plaintext of the connection to be duplicated to stdout.
|
||||||
// c.p = xml.NewParser(tee{c.tls, os.Stdout});
|
//c.p = xml.NewDecoder(tee{c.tls, os.Stdout});
|
||||||
c.p = xml.NewDecoder(c.tls)
|
c.p = xml.NewDecoder(c.tls)
|
||||||
|
|
||||||
a := strings.SplitN(user, "@", 2)
|
a := strings.SplitN(user, "@", 2)
|
||||||
@ -279,12 +279,12 @@ type tlsFailure struct {
|
|||||||
|
|
||||||
type saslMechanisms struct {
|
type saslMechanisms struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"`
|
||||||
Mechanism []string
|
Mechanism []string `xml:"mechanism"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslAuth struct {
|
type saslAuth struct {
|
||||||
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"`
|
XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl auth"`
|
||||||
Mechanism string `xml:"attr"`
|
Mechanism string `xml:",attr"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type saslChallenge string
|
type saslChallenge string
|
||||||
@ -316,10 +316,10 @@ type bindBind struct {
|
|||||||
|
|
||||||
type clientMessage struct {
|
type clientMessage struct {
|
||||||
XMLName xml.Name `xml:"jabber:client message"`
|
XMLName xml.Name `xml:"jabber:client message"`
|
||||||
From string `xml:"attr"`
|
From string `xml:",attr"`
|
||||||
Id string `xml:"attr"`
|
Id string `xml:",attr"`
|
||||||
To string `xml:"attr"`
|
To string `xml:",attr"`
|
||||||
Type string `xml:"attr"` // chat, error, groupchat, headline, or normal
|
Type string `xml:",attr"` // chat, error, groupchat, headline, or normal
|
||||||
|
|
||||||
// These should technically be []clientText,
|
// These should technically be []clientText,
|
||||||
// but string is much more convenient.
|
// but string is much more convenient.
|
||||||
@ -329,17 +329,17 @@ type clientMessage struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type clientText struct {
|
type clientText struct {
|
||||||
Lang string `xml:"attr"`
|
Lang string `xml:",attr"`
|
||||||
Body string `xml:"chardata"`
|
Body string `xml:"chardata"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientPresence struct {
|
type clientPresence struct {
|
||||||
XMLName xml.Name `xml:"jabber:client presence"`
|
XMLName xml.Name `xml:"jabber:client presence"`
|
||||||
From string `xml:"attr"`
|
From string `xml:",attr"`
|
||||||
Id string `xml:"attr"`
|
Id string `xml:",attr"`
|
||||||
To string `xml:"attr"`
|
To string `xml:",attr"`
|
||||||
Type string `xml:"attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
Type string `xml:",attr"` // error, probe, subscribe, subscribed, unavailable, unsubscribe, unsubscribed
|
||||||
Lang string `xml:"attr"`
|
Lang string `xml:",attr"`
|
||||||
|
|
||||||
Show string // away, chat, dnd, xa
|
Show string // away, chat, dnd, xa
|
||||||
Status string // sb []clientText
|
Status string // sb []clientText
|
||||||
@ -349,18 +349,18 @@ type clientPresence struct {
|
|||||||
|
|
||||||
type clientIQ struct { // info/query
|
type clientIQ struct { // info/query
|
||||||
XMLName xml.Name `xml:"jabber:client iq"`
|
XMLName xml.Name `xml:"jabber:client iq"`
|
||||||
From string `xml:"attr"`
|
From string `xml:",attr"`
|
||||||
Id string `xml:"attr"`
|
Id string `xml:",attr"`
|
||||||
To string `xml:"attr"`
|
To string `xml:",attr"`
|
||||||
Type string `xml:"attr"` // error, get, result, set
|
Type string `xml:",attr"` // error, get, result, set
|
||||||
Error clientError
|
Error clientError
|
||||||
Bind bindBind
|
Bind bindBind
|
||||||
}
|
}
|
||||||
|
|
||||||
type clientError struct {
|
type clientError struct {
|
||||||
XMLName xml.Name `xml:"jabber:client error"`
|
XMLName xml.Name `xml:"jabber:client error"`
|
||||||
Code string `xml:"attr"`
|
Code string `xml:",attr"`
|
||||||
Type string `xml:"attr"`
|
Type string `xml:",attr"`
|
||||||
Any xml.Name
|
Any xml.Name
|
||||||
Text string
|
Text string
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user