edgerouter

package module
v0.0.0-...-e1c98eb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoSuchConnection = errors.New("no such connection")

Functions

func Unmarsall

func Unmarsall(bts []byte, v interface{}) error

Types

type BytesMessage

type BytesMessage struct {
	Message []byte
	To      string
	For     Device
}

func NewBytesMessage

func NewBytesMessage(v interface{}, to string, d Device) *BytesMessage

type Component

type Component struct {
	ER     EdgeRouter
	Server Server
	Trans  Transport
	Ctrl   Controller
}

func (Component) String

func (c Component) String() string

type Controller

type Controller interface {
	OnReceived(bts []byte, conn net.Conn) int
	SetTransport(Transport)
	SetHandler(handler interface{}) error
	Run()
}

type Device

type Device interface {
	DeviceID() string
	DeviceType() string
}

type EdgeRouter

type EdgeRouter struct {
	Name    string
	Plugins map[string]interface{}
	// contains filtered or unexported fields
}

func Organize

func Organize(name string, plugins ...interface{}) *EdgeRouter

func (*EdgeRouter) ConfigBy

func (er *EdgeRouter) ConfigBy(filename string) error

func (*EdgeRouter) ConfigByString

func (er *EdgeRouter) ConfigByString(str string) error

func (*EdgeRouter) Run

func (er *EdgeRouter) Run()

type Initer

type Initer interface {
	Init() error
}

type SerialSeekHandler

type SerialSeekHandler interface {
	PacketSend() []*BytesMessage
	SeekReceived([]byte, Device) (handled_length int, shouldStartNew bool)
}

type SerialSeeker

type SerialSeeker struct {
	Period  string
	TimeOut string
	// contains filtered or unexported fields
}

func (*SerialSeeker) Init

func (s *SerialSeeker) Init() (err error)

func (*SerialSeeker) OnReceived

func (s *SerialSeeker) OnReceived(bts []byte, conn net.Conn) int

func (*SerialSeeker) Run

func (s *SerialSeeker) Run()

func (*SerialSeeker) SetHandler

func (s *SerialSeeker) SetHandler(handler interface{}) error

func (*SerialSeeker) SetTransport

func (s *SerialSeeker) SetTransport(t Transport)

func (*SerialSeeker) String

func (s *SerialSeeker) String() string

type Server

type Server interface {
	Run()
}

type TcpClient

type TcpClient struct {
	Port int
	// contains filtered or unexported fields
}

func (*TcpClient) Close

func (c *TcpClient) Close(toDel *net.TCPConn)

func (*TcpClient) Connect

func (c *TcpClient) Connect(to string) error

func (*TcpClient) DeleteConn

func (c *TcpClient) DeleteConn(toDel net.Conn)

TODO client should reconnect to server

func (*TcpClient) GetConn

func (c *TcpClient) GetConn(to string, unexceptedConns []net.Conn) (conn net.Conn, err error)

func (*TcpClient) Init

func (c *TcpClient) Init()

func (*TcpClient) PacketReceived

func (c *TcpClient) PacketReceived(bts []byte, conn *net.TCPConn) int

func (*TcpClient) SetController

func (c *TcpClient) SetController(ctrl Controller)

func (*TcpClient) String

func (c *TcpClient) String() string

type TcpHandler

type TcpHandler interface {
	PacketReceived(bts []byte, conn *net.TCPConn) int
	Close(*net.TCPConn)
}

type TcpServer

type TcpServer struct {
	Port int
	// contains filtered or unexported fields
}

func (*TcpServer) Close

func (c *TcpServer) Close(toDel *net.TCPConn)

func (*TcpServer) Connect

func (c *TcpServer) Connect(to string) error

func (*TcpServer) DeleteConn

func (c *TcpServer) DeleteConn(toDel net.Conn)

func (*TcpServer) GetConn

func (c *TcpServer) GetConn(to string, unexceptedConns []net.Conn) (conn net.Conn, err error)

func (*TcpServer) Init

func (s *TcpServer) Init() (err error)

func (*TcpServer) PacketReceived

func (c *TcpServer) PacketReceived(bts []byte, conn *net.TCPConn) int

func (*TcpServer) Run

func (s *TcpServer) Run()

func (*TcpServer) SetController

func (c *TcpServer) SetController(ctrl Controller)

func (*TcpServer) String

func (c *TcpServer) String() string

type Transport

type Transport interface {
	Connect(string) error
	// Send(*BytesMessage) error
	SetController(Controller)
	GetConn(addr string, unexceptedConns []net.Conn) (net.Conn, error)
	DeleteConn(net.Conn)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL