From 0d259f5448fadf3866afee87d4dc3ac0b2ee47db Mon Sep 17 00:00:00 2001 From: Teoman Soygul Date: Mon, 29 Dec 2014 01:16:23 +0100 Subject: [PATCH 1/2] add doc clarifications --- xmpp.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/xmpp.go b/xmpp.go index e669c92..916108f 100644 --- a/xmpp.go +++ b/xmpp.go @@ -502,14 +502,13 @@ func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error) } // IsEncrypted will return true if the client is connected using a TLS transport, either because it used -// TLS to connect from the outset, or because it successfully used STARTTLS to promote a TCP connection -// to TLS. +// TLS to connect from the outset, or because it successfully used STARTTLS to promote a TCP connection to TLS. func (c *Client) IsEncrypted() bool { _, ok := c.conn.(*tls.Conn) return ok } -// Chat is an incoming or outgoing XMPP chat message +// Chat is an incoming or outgoing XMPP chat message. type Chat struct { Remote string Type string @@ -517,7 +516,7 @@ type Chat struct { Other []string } -// Presence is an XMPP presence message +// Presence is an XMPP presence notification. type Presence struct { From string To string @@ -525,8 +524,9 @@ type Presence struct { Show string } -// Recv wait next token of chat. -func (c *Client) Recv() (event interface{}, err error) { +// Recv waits to receive the next XMPP stanza. +// Return type is either a presence notification or a chat message. +func (c *Client) Recv() (stanza interface{}, err error) { for { _, val, err := next(c.p) if err != nil { @@ -542,10 +542,9 @@ func (c *Client) Recv() (event interface{}, err error) { panic("unreachable") } -// Send sends message text. +// Send sends the message wrapped inside an XMPP message stanza body. func (c *Client) Send(chat Chat) (n int, err error) { - return fmt.Fprintf(c.conn, ""+ - "%s", + return fmt.Fprintf(c.conn, ""+"%s", xmlEscape(chat.Remote), xmlEscape(chat.Type), xmlEscape(chat.Text)) } From 050bbf66bd396c528d944c053aa2fef37d0965a0 Mon Sep 17 00:00:00 2001 From: Teoman Soygul Date: Tue, 30 Dec 2014 01:53:23 +0100 Subject: [PATCH 2/2] some formatting --- xmpp.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/xmpp.go b/xmpp.go index 916108f..e86eec4 100644 --- a/xmpp.go +++ b/xmpp.go @@ -501,7 +501,7 @@ func (c *Client) startStream(o *Options, domain string) (*streamFeatures, error) return f, nil } -// IsEncrypted will return true if the client is connected using a TLS transport, either because it used +// IsEncrypted will return true if the client is connected using a TLS transport, either because it used. // TLS to connect from the outset, or because it successfully used STARTTLS to promote a TCP connection to TLS. func (c *Client) IsEncrypted() bool { _, ok := c.conn.(*tls.Conn) @@ -569,7 +569,6 @@ type streamError struct { } // RFC 3920 C.3 TLS name space - type tlsStartTLS struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-tls starttls"` Required *string `xml:"required"` @@ -584,7 +583,6 @@ type tlsFailure struct { } // RFC 3920 C.4 SASL name space - type saslMechanisms struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-sasl mechanisms"` Mechanism []string `xml:"mechanism"` @@ -615,7 +613,6 @@ type saslFailure struct { } // RFC 3920 C.5 Resource binding name space - type bindBind struct { XMLName xml.Name `xml:"urn:ietf:params:xml:ns:xmpp-bind bind"` Resource string @@ -623,7 +620,6 @@ type bindBind struct { } // RFC 3921 B.1 jabber:client - type clientMessage struct { XMLName xml.Name `xml:"jabber:client message"` From string `xml:"from,attr"` @@ -631,8 +627,7 @@ type clientMessage struct { To string `xml:"to,attr"` Type string `xml:"type,attr"` // chat, error, groupchat, headline, or normal - // These should technically be []clientText, - // but string is much more convenient. + // These should technically be []clientText, but string is much more convenient. Subject string `xml:"subject"` Body string `xml:"body"` Thread string `xml:"thread"`