mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-27 12:52:02 -08:00
Improve code documentation
This commit is contained in:
parent
7e50d313ea
commit
ca148e5fe5
4
doc.go
4
doc.go
@ -4,10 +4,8 @@ Fluux XMPP is a Go XMPP library, focusing on simplicity, simple automation, and
|
|||||||
The goal is to make simple to write simple adhoc XMPP clients:
|
The goal is to make simple to write simple adhoc XMPP clients:
|
||||||
|
|
||||||
- For automation (like for example monitoring of an XMPP service),
|
- For automation (like for example monitoring of an XMPP service),
|
||||||
|
|
||||||
- For building connected "things" by plugging them on an XMPP server,
|
- For building connected "things" by plugging them on an XMPP server,
|
||||||
|
- For writing simple chatbots to control a service or a thing.
|
||||||
- For writing simple chatbot to control a service or a thing.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package xmpp
|
package xmpp
|
||||||
|
11
iq.go
11
iq.go
@ -16,6 +16,9 @@ TODO support ability to put Raw payload
|
|||||||
// ============================================================================
|
// ============================================================================
|
||||||
// XMPP Errors
|
// XMPP Errors
|
||||||
|
|
||||||
|
// Err is an XMPP stanza payload that is used to report error on message,
|
||||||
|
// presence or iq stanza.
|
||||||
|
// It is intended to be added in the payload of the erroneous stanza.
|
||||||
type Err struct {
|
type Err struct {
|
||||||
XMLName xml.Name `xml:"error"`
|
XMLName xml.Name `xml:"error"`
|
||||||
Code int `xml:"code,attr,omitempty"`
|
Code int `xml:"code,attr,omitempty"`
|
||||||
@ -250,6 +253,8 @@ type IQPayload interface {
|
|||||||
IsIQPayload()
|
IsIQPayload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Node is a generic structure to represent XML data. It is used to parse
|
||||||
|
// unreferenced or custom stanza payload.
|
||||||
type Node struct {
|
type Node struct {
|
||||||
XMLName xml.Name
|
XMLName xml.Name
|
||||||
Attrs []xml.Attr `xml:"-"`
|
Attrs []xml.Attr `xml:"-"`
|
||||||
@ -257,11 +262,15 @@ type Node struct {
|
|||||||
Nodes []Node `xml:",any"`
|
Nodes []Node `xml:",any"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Attr represents generic XML attributes, as used on the generic XML Node
|
||||||
|
// representation.
|
||||||
type Attr struct {
|
type Attr struct {
|
||||||
K string
|
K string
|
||||||
V string
|
V string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalXML is a custom unmarshal function used by xml.Unmarshal to
|
||||||
|
// transform generic XML content into hierarchical Node structure.
|
||||||
func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
||||||
// Assign "n.Attrs = start.Attr", without repeating xmlns in attributes:
|
// Assign "n.Attrs = start.Attr", without repeating xmlns in attributes:
|
||||||
for _, attr := range start.Attr {
|
for _, attr := range start.Attr {
|
||||||
@ -274,6 +283,8 @@ func (n *Node) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|||||||
return d.DecodeElement((*node)(n), &start)
|
return d.DecodeElement((*node)(n), &start)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalXML is a custom XML serializer used by xml.Marshal to serialize a
|
||||||
|
// Node structure to XML.
|
||||||
func (n Node) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error) {
|
func (n Node) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error) {
|
||||||
start.Attr = n.Attrs
|
start.Attr = n.Attrs
|
||||||
start.Name = n.XMLName
|
start.Name = n.XMLName
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package xmpp
|
package xmpp // import "fluux.io/xmpp"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package xmpp
|
package xmpp // import "fluux.io/xmpp"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
|
Loading…
Reference in New Issue
Block a user