75 Chardata string `xml:",chardata"` |
75 Chardata string `xml:",chardata"` |
76 Mechanism string `xml:"mechanism,attr,omitempty"` |
76 Mechanism string `xml:"mechanism,attr,omitempty"` |
77 Any *Generic |
77 Any *Generic |
78 } |
78 } |
79 |
79 |
|
80 type Stanzer interface { |
|
81 GetHeader() *Header |
|
82 } |
|
83 |
80 // One of the three core XMPP stanza types: iq, message, presence. See |
84 // One of the three core XMPP stanza types: iq, message, presence. See |
81 // RFC3920, section 9. |
85 // RFC3920, section 9. |
82 type Stanza struct { |
86 type Header struct { |
83 To string `xml:"to,attr,omitempty"` |
87 To string `xml:"to,attr,omitempty"` |
84 From string `xml:"from,attr,omitempty"` |
88 From string `xml:"from,attr,omitempty"` |
85 Id string `xml:"id,attr,omitempty"` |
89 Id string `xml:"id,attr,omitempty"` |
86 Type string `xml:"type,attr,omitempty"` |
90 Type string `xml:"type,attr,omitempty"` |
87 Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr,omitempty"` |
91 Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr,omitempty"` |
91 } |
95 } |
92 |
96 |
93 // message stanza |
97 // message stanza |
94 type Message struct { |
98 type Message struct { |
95 XMLName xml.Name `xml:"message"` |
99 XMLName xml.Name `xml:"message"` |
96 Stanza |
100 Header |
97 Subject *Generic `xml:"subject"` |
101 Subject *Generic `xml:"subject"` |
98 Body *Generic `xml:"body"` |
102 Body *Generic `xml:"body"` |
99 Thread *Generic `xml:"thread"` |
103 Thread *Generic `xml:"thread"` |
100 } |
104 } |
|
105 var _ Stanzer = &Message{} |
101 |
106 |
102 // presence stanza |
107 // presence stanza |
103 type Presence struct { |
108 type Presence struct { |
104 XMLName xml.Name `xml:"presence"` |
109 XMLName xml.Name `xml:"presence"` |
105 Stanza |
110 Header |
106 Show *Generic `xml:"show"` |
111 Show *Generic `xml:"show"` |
107 Status *Generic `xml:"status"` |
112 Status *Generic `xml:"status"` |
108 Priority *Generic `xml:"priority"` |
113 Priority *Generic `xml:"priority"` |
109 } |
114 } |
|
115 var _ Stanzer = &Presence{} |
110 |
116 |
111 // iq stanza |
117 // iq stanza |
112 type Iq struct { |
118 type Iq struct { |
113 XMLName xml.Name `xml:"iq"` |
119 XMLName xml.Name `xml:"iq"` |
114 Stanza |
120 Header |
115 } |
121 } |
|
122 var _ Stanzer = &Iq{} |
116 |
123 |
117 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
124 // Describes an XMPP stanza error. See RFC 3920, Section 9.3. |
118 type Error struct { |
125 type Error struct { |
119 XMLName xml.Name `xml:"error"` |
126 XMLName xml.Name `xml:"error"` |
120 // The error type attribute. |
127 // The error type attribute. |