From 229e8eef7bef51ff5a72f091594381b82a7ae409 Mon Sep 17 00:00:00 2001 From: Emir Aganovic Date: Wed, 21 Dec 2022 20:43:29 +0100 Subject: [PATCH] Minor fixing --- README.md | 1 + transport/layer.go | 2 +- transport/tcp.go | 6 +++--- transport/udp.go | 9 +++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 92fea13..97cf0ca 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ srv.OnBye(byeHandler) // Add listeners srv.Listen("udp", "127.0.0.1:5060") srv.Listen("tcp", "127.0.0.1:5061") +srv.Listen("ws", "127.0.0.1:5080") ... // fire server srv.Serve() diff --git a/transport/layer.go b/transport/layer.go index b334916..349cf9e 100644 --- a/transport/layer.go +++ b/transport/layer.go @@ -154,7 +154,7 @@ func (l *Layer) Serve(ctx context.Context, network string, addr string) error { case "tls": fallthrough default: - return fmt.Errorf("Protocol not supported yet") + return fmt.Errorf("protocol not supported yet") } // Add transport to list diff --git a/transport/tcp.go b/transport/tcp.go index 94fabb2..7931fa5 100644 --- a/transport/tcp.go +++ b/transport/tcp.go @@ -52,18 +52,18 @@ func (t *TCPTransport) Network() string { func (t *TCPTransport) Close() error { // return t.connections.Done() - var err error + var rerr error if t.listener == nil { return nil } if err := t.listener.Close(); err != nil { - err = fmt.Errorf("err=%w", err) + rerr = fmt.Errorf("err=%w", err) } t.listener = nil // t.listenerTCP = nil - return err + return rerr } // TODO diff --git a/transport/udp.go b/transport/udp.go index e1e65d0..a4b83ad 100644 --- a/transport/udp.go +++ b/transport/udp.go @@ -80,23 +80,24 @@ func (t *UDPTransport) Network() string { func (t *UDPTransport) Close() error { // return t.connections.Done() - var err error if t.listener == nil { return nil } + var rerr error if err := t.listener.Close(); err != nil { - err = fmt.Errorf("%w", err) + rerr = err } if err := t.listenerUDP.Close(); err != nil { - err = fmt.Errorf("%w", err) + rerr = fmt.Errorf("%w.%w", err, rerr) } t.listener = nil t.listenerUDP = nil t.conn = nil - return err + + return rerr } // TODO