Skip to content

Commit

Permalink
Refactor code to reflect refactored sugoi code
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairhamed committed Nov 20, 2015
1 parent ce6b42f commit cb1647c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
11 changes: 11 additions & 0 deletions canopus.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,15 @@ type CoapServer interface {

IsDuplicateMessage(msg *Message) bool
UpdateMessageTS(msg *Message)
}

// A simple wrapper interface around a connection
// This was primarily concieved so that mocks could be
// created to unit test connection code
type CanopusConnection interface {
GetConnection() net.Conn
Write(b []byte) (int, error)
SetReadDeadline(t time.Time) error
Read() (buf []byte, n int, err error)
WriteTo(b []byte, addr net.Addr) (int, error)
}
11 changes: 0 additions & 11 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@ import (
"time"
)

// A simple wrapper interface around a connection
// This was primarily concieved so that mocks could be
// created to unit test connection code
type CanopusConnection interface {
GetConnection() net.Conn
Write(b []byte) (int, error)
SetReadDeadline(t time.Time) error
Read() (buf []byte, n int, err error)
WriteTo(b []byte, addr net.Addr) (int, error)
}

// ----------------------------------------------------------------

func NewCanopusUDPConnection(c *net.UDPConn) CanopusConnection {
Expand Down
13 changes: 6 additions & 7 deletions examples/proxy-reverse/run-example.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package main
import "github.com/zubairhamed/canopus"

func main() {

Expand All @@ -8,12 +7,12 @@ func main() {
out string
}

var server *canopus.CoapServer
server.AddProxyPass(in, out)
server.RemoveProxyPass(in)

server.AddProxyPassReverse(in, out)
server.AddRemoveProxyPassReverse
// var server *canopus.CoapServer
// server.AddProxyPass(in, out)
// server.RemoveProxyPass(in)
//
// server.AddProxyPassReverse(in, out)
// server.AddRemoveProxyPassReverse


}
4 changes: 1 addition & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,7 @@ func (s *DefaultCoapServer) RemoveObservation(resource string, addr *net.UDPAddr
}

func (c *DefaultCoapServer) Dial(host string) {
remoteAddr, _ := net.ResolveUDPAddr("udp6", host)

c.remoteAddr = remoteAddr
c.Dial6(host)
}

func (c *DefaultCoapServer) Dial6(host string) {
Expand Down

0 comments on commit cb1647c

Please sign in to comment.