From f482858a5276af9608c84f40dbc712f293e10c68 Mon Sep 17 00:00:00 2001 From: mattn Date: Thu, 9 Feb 2012 14:44:44 +0900 Subject: [PATCH] go fix. --- xmpp.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xmpp.go b/xmpp.go index 7d022a3..69d83f5 100644 --- a/xmpp.go +++ b/xmpp.go @@ -42,7 +42,7 @@ var DefaultConfig tls.Config type Client struct { tls *tls.Conn // connection to server jid string // Jabber ID for our connection - p *xml.Parser + p *xml.Decoder } // NewClient creates a new connection to a host given as "hostname" or "hostname:port". @@ -120,7 +120,7 @@ func (c *Client) Close() error { func (c *Client) init(user, passwd string) error { // 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.NewParser(c.tls) + c.p = xml.NewDecoder(c.tls) a := strings.SplitN(user, "@", 2) if len(a) != 2 { @@ -148,7 +148,7 @@ func (c *Client) init(user, passwd string) error { // Next message should be to tell us authentication options. // See section 4.6 in RFC 3920. var f streamFeatures - if err = c.p.Unmarshal(&f, nil); err != nil { + if err = c.p.DecodeElement(&f, nil); err != nil { return errors.New("unmarshal : " + err.Error()) } havePlain := false @@ -195,7 +195,7 @@ func (c *Client) init(user, passwd string) error { if se.Name.Space != nsStream || se.Name.Local != "stream" { return errors.New("expected , got <" + se.Name.Local + "> in " + se.Name.Space) } - if err = c.p.Unmarshal(&f, nil); err != nil { + if err = c.p.DecodeElement(&f, nil); err != nil { // TODO: often stream stop. //return os.NewError("unmarshal : " + err.String()) } @@ -203,7 +203,7 @@ func (c *Client) init(user, passwd string) error { // Send IQ message asking to bind to the local user name. fmt.Fprintf(c.tls, "\n", nsBind) var iq clientIQ - if err = c.p.Unmarshal(&iq, nil); err != nil { + if err = c.p.DecodeElement(&iq, nil); err != nil { return errors.New("unmarshal : " + err.Error()) } if &iq.Bind == nil { @@ -366,7 +366,7 @@ type clientError struct { } // Scan XML token stream to find next StartElement. -func nextStart(p *xml.Parser) (xml.StartElement, error) { +func nextStart(p *xml.Decoder) (xml.StartElement, error) { for { t, err := p.Token() if err != nil { @@ -383,7 +383,7 @@ func nextStart(p *xml.Parser) (xml.StartElement, error) { // Scan XML token stream for next element and save into val. // If val == nil, allocate new element based on proto map. // Either way, return val. -func next(p *xml.Parser) (xml.Name, interface{}, error) { +func next(p *xml.Decoder) (xml.Name, interface{}, error) { // Read start element to find out what type we want. se, err := nextStart(p) if err != nil { @@ -431,7 +431,7 @@ func next(p *xml.Parser) (xml.Name, interface{}, error) { } // Unmarshal into that storage. - if err = p.Unmarshal(nv, &se); err != nil { + if err = p.DecodeElement(nv, &se); err != nil { return xml.Name{}, nil, err } return se.Name, nv, err