# HG changeset patch # User Chris Jones # Date 1355722677 25200 # Node ID bd56fb741f69e13eba06ff5c0b6d6d5d368f6acc # Parent 36287f2cf06e594832f7de3c6dd81dd7bbf89b18 Step 2 of converting to interface Stanza and embedded struct Header. diff -r 36287f2cf06e -r bd56fb741f69 stream.go --- a/stream.go Sun Dec 16 22:36:53 2012 -0700 +++ b/stream.go Sun Dec 16 22:37:57 2012 -0700 @@ -148,7 +148,7 @@ // If it's a Stanza, we try to unmarshal its innerxml // into objects of the appropriate respective // types. This is specified by our extensions. - if st, ok := obj.(Stanzer) ; ok { + if st, ok := obj.(Stanza) ; ok { err = parseExtended(st.GetHeader(), extStanza) if err != nil { Warn.Logf("ext unmarshal: %s", err) @@ -250,7 +250,7 @@ cl.handleTls(obj) case *auth: cl.handleSasl(obj) - case Stanzer: + case Stanza: st = obj.GetHeader() default: Warn.Logf("Unhandled non-stanza: %T %#v", x, x) diff -r 36287f2cf06e -r bd56fb741f69 structs.go --- a/structs.go Sun Dec 16 22:36:53 2012 -0700 +++ b/structs.go Sun Dec 16 22:37:57 2012 -0700 @@ -77,7 +77,7 @@ Any *Generic } -type Stanzer interface { +type Stanza interface { GetHeader() *Header } @@ -102,7 +102,7 @@ Body *Generic `xml:"body"` Thread *Generic `xml:"thread"` } -var _ Stanzer = &Message{} +var _ Stanza = &Message{} // presence stanza type Presence struct { @@ -112,14 +112,14 @@ Status *Generic `xml:"status"` Priority *Generic `xml:"priority"` } -var _ Stanzer = &Presence{} +var _ Stanza = &Presence{} // iq stanza type Iq struct { XMLName xml.Name `xml:"iq"` Header } -var _ Stanzer = &Iq{} +var _ Stanza = &Iq{} // Describes an XMPP stanza error. See RFC 3920, Section 9.3. type Error struct {