Comments clean-up

This commit is contained in:
Mickael Remond 2019-11-04 12:58:10 +01:00
parent 0227596f90
commit 1d7db9ceee
No known key found for this signature in database
GPG key ID: E6F6045D79965AA3
3 changed files with 12 additions and 11 deletions

View file

@ -4,9 +4,9 @@ import (
"os"
)
// Config & TransportConfiguration must not be modified after having been passed to NewClient. Any
// changes made after connecting are ignored.
type Config struct {
// TransportConfiguration must not be modified after having been passed to NewClient. Any
// changes made after connecting are ignored.
TransportConfiguration
Jid string

View file

@ -19,21 +19,21 @@ func newStreamLogger(conn io.ReadWriter, logFile io.Writer) io.ReadWriter {
}
}
func (sp *streamLogger) Read(p []byte) (n int, err error) {
n, err = sp.socket.Read(p)
func (sl *streamLogger) Read(p []byte) (n int, err error) {
n, err = sl.socket.Read(p)
if n > 0 {
sp.logFile.Write([]byte("RECV:\n")) // Prefix
if n, err := sp.logFile.Write(p[:n]); err != nil {
sl.logFile.Write([]byte("RECV:\n")) // Prefix
if n, err := sl.logFile.Write(p[:n]); err != nil {
return n, err
}
sp.logFile.Write([]byte("\n\n")) // Separator
sl.logFile.Write([]byte("\n\n")) // Separator
}
return
}
func (sp *streamLogger) Write(p []byte) (n int, err error) {
sp.logFile.Write([]byte("SEND:\n")) // Prefix
for _, w := range []io.Writer{sp.socket, sp.logFile} {
func (sl *streamLogger) Write(p []byte) (n int, err error) {
sl.logFile.Write([]byte("SEND:\n")) // Prefix
for _, w := range []io.Writer{sl.socket, sl.logFile} {
n, err = w.Write(p)
if err != nil {
return
@ -43,7 +43,7 @@ func (sp *streamLogger) Write(p []byte) (n int, err error) {
return
}
}
sp.logFile.Write([]byte("\n\n")) // Separator
sl.logFile.Write([]byte("\n\n")) // Separator
return len(p), nil
}

View file

@ -12,6 +12,7 @@ import (
var ErrTransportProtocolNotSupported = errors.New("Transport protocol not supported")
var ErrTLSNotSupported = errors.New("Transport does not support StartTLS")
// TODO: rename to transport config?
type TransportConfiguration struct {
// Address is the XMPP Host and port to connect to. Host is of
// the form 'serverhost:port' i.e "localhost:8888"