Skip to content

Commit

Permalink
Add more comments, finish manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkren committed Sep 17, 2019
1 parent a790f2c commit 3e295fd
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 215 deletions.
3 changes: 1 addition & 2 deletions pkg/app2/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import (
"net"
"net/rpc"

"github.com/skycoin/dmsg/netutil"

"github.com/skycoin/dmsg/cipher"
"github.com/skycoin/dmsg/netutil"
"github.com/skycoin/skycoin/src/util/logging"

"github.com/skycoin/skywire/pkg/routing"
Expand Down
23 changes: 15 additions & 8 deletions pkg/app2/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ import (
"net"
"time"

"github.com/pkg/errors"
"github.com/skycoin/skywire/pkg/routing"
)

// Conn is a connection from app client to the server.
// Implements `net.Conn`.
type Conn struct {
id uint16
rpc ServerRPCClient
local routing.Addr
remote routing.Addr
id uint16
rpc ServerRPCClient
local routing.Addr
remote routing.Addr
freeLocalPort func()
}

func (c *Conn) Read(b []byte) (int, error) {
Expand All @@ -25,6 +26,12 @@ func (c *Conn) Write(b []byte) (int, error) {
}

func (c *Conn) Close() error {
defer func() {
if c.freeLocalPort != nil {
c.freeLocalPort()
}
}()

return c.rpc.CloseConn(c.id)
}

Expand All @@ -37,13 +44,13 @@ func (c *Conn) RemoteAddr() net.Addr {
}

func (c *Conn) SetDeadline(t time.Time) error {
return errors.New("method not implemented")
return errMethodNotImplemented
}

func (c *Conn) SetReadDeadline(t time.Time) error {
return errors.New("method not implemented")
return errMethodNotImplemented
}

func (c *Conn) SetWriteDeadline(t time.Time) error {
return errors.New("method not implemented")
return errMethodNotImplemented
}
90 changes: 0 additions & 90 deletions pkg/app2/conns_manager.go

This file was deleted.

7 changes: 7 additions & 0 deletions pkg/app2/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@ package app2
import "github.com/pkg/errors"

var (
// ErrPortAlreadyBound is being returned when trying to bind to the port
// which is already bound to.
ErrPortAlreadyBound = errors.New("port is already bound")
)

var (
// errMethodNotImplemented serves as a return value for non-implemented funcs (stubs).
errMethodNotImplemented = errors.New("method not implemented")
)
1 change: 1 addition & 0 deletions pkg/app2/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

// Listener is a listener for app server connections.
// Implements `net.Listener`.
type Listener struct {
id uint16
rpc ServerRPCClient
Expand Down
90 changes: 0 additions & 90 deletions pkg/app2/listeners_manager.go

This file was deleted.

Loading

0 comments on commit 3e295fd

Please sign in to comment.