Skip to content

Commit

Permalink
Minor fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
emiago committed Dec 21, 2022
1 parent 00e905d commit 229e8ee
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion transport/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions transport/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions transport/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 229e8ee

Please sign in to comment.