gateway

package
v0.0.0-...-b83f79d Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2015 License: EPL-1.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	/* Config Errors */
	ErrMissingValueForConfigOption  = errors.New("Missing value for config option")
	ErrTooManyValuesForConfigOption = errors.New("Too many values for config option")
	ErrUnknownConfigOption          = errors.New("Unknown config option")
	ErrNoTransportSpecified         = errors.New("Missing transport")
	ErrInvalidModeSpecified         = errors.New("Invalid mode")
	ErrNotANumber                   = errors.New("Not a number")

	/* Protocol Errors */
	ErrZeroLengthClientID = errors.New("Zero-length clientID is invalid")
	ErrClientIDTooLong    = errors.New("ClientID too long")

	/* Topic Errors */
	ErrTopicFilterEmptyString     = errors.New("TopicFilter cannot be empty string")
	ErrTopicFilterInvalidWildcard = errors.New("TopicFilter contains invalid wildcard")
	ErrTopicNameEmptyString       = errors.New("TopicName cannot be empty string")
	ErrTopicNameContainsWildcard  = errors.New("TopicName cannot contain wildcard")

	/* Topic Tree Errors */
	ErrNoSuchSubscriptionExists = errors.New("Subscription does not exist")
	ErrNoSubscribers            = errors.New("No subscribers")
	ErrClientNotSubscribed      = errors.New("Client not subscribed")
)
View Source
var (
	INFO  *log.Logger
	ERROR *log.Logger
)

Functions

func ContainsWildcard

func ContainsWildcard(topic string) bool

func InitLogger

func InitLogger(infoHandle, errorHandle io.Writer)

func ValidateTopicFilter

func ValidateTopicFilter(topic string) ([]string, error)

func ValidateTopicName

func ValidateTopicName(topic string) ([]string, error)

Types

type AGateway

type AGateway struct {
	// contains filtered or unexported fields
}

func NewAGateway

func NewAGateway(gc *GatewayConfig, stopsig chan os.Signal) *AGateway

func (*AGateway) OnPacket

func (ag *AGateway) OnPacket(nbytes int, buffer []byte, con *net.UDPConn, addr *net.UDPAddr)

func (*AGateway) Port

func (ag *AGateway) Port() int

func (*AGateway) Start

func (ag *AGateway) Start()

type Client

type Client struct {
	sync.RWMutex
	ClientId string
	Conn     *net.UDPConn
	Address  *net.UDPAddr
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ClientId string, Conn *net.UDPConn, Address *net.UDPAddr) *Client

func (*Client) AddPendingMessage

func (c *Client) AddPendingMessage(p *P.PublishMessage)

func (*Client) AddrString

func (c *Client) AddrString() string

func (*Client) FetchPendingMessage

func (c *Client) FetchPendingMessage(topicId uint16) *P.PublishMessage

func (*Client) Register

func (c *Client) Register(topicId uint16, topic string)

func (*Client) Registered

func (c *Client) Registered(topicId uint16) bool

func (*Client) String

func (c *Client) String() string

func (*Client) Write

func (c *Client) Write(m P.Message) error

type Clients

type Clients struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Clients) AddClient

func (c *Clients) AddClient(client SNClient) bool

Return true if this is a new client, false otherwise Clients are indexed by their address:port b/c that's the only indentifying information we have outside of a CONNECT packet

func (*Clients) GetClient

func (c *Clients) GetClient(addr *net.UDPAddr) SNClient

func (*Clients) RemoveClient

func (c *Clients) RemoveClient(id string)

type Gateway

type Gateway interface {
	Start()
	Port() int
	OnPacket(int, []byte, *net.UDPConn, *net.UDPAddr)
}

type GatewayConfig

type GatewayConfig struct {
	// contains filtered or unexported fields
}

func ParseConfigFile

func ParseConfigFile(file string) (*GatewayConfig, error)

func (*GatewayConfig) IsAggregating

func (gc *GatewayConfig) IsAggregating() bool

type SNClient

type SNClient interface {
	AddrString() string
}

type TClient

type TClient struct {
	Client
	// contains filtered or unexported fields
}

func NewTClient

func NewTClient(ClientId, Broker string, Connection *net.UDPConn, Address *net.UDPAddr) (*TClient, error)

Do not allow the creation of an MQTT-SN client if a connection to the MQTT broker cannot be established

type TGateway

type TGateway struct {
	// contains filtered or unexported fields
}

func NewTGateway

func NewTGateway(gc *GatewayConfig, stopsig chan os.Signal) *TGateway

func (*TGateway) OnPacket

func (t *TGateway) OnPacket(nbytes int, buffer []byte, con *net.UDPConn, addr *net.UDPAddr)

func (*TGateway) Port

func (t *TGateway) Port() int

func (*TGateway) Start

func (t *TGateway) Start()

type TopicTree

type TopicTree struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewTopicTree

func NewTopicTree() *TopicTree

func (*TopicTree) AddSubscription

func (tt *TopicTree) AddSubscription(client *Client, topic string) (bool, error)

return false if there is already a subscriber of this topic, true if this is the first subscriber

func (*TopicTree) RemoveSubscription

func (tt *TopicTree) RemoveSubscription(s *Client, topic string) error

topic could contain wild cards, however we do only consider the literal topic string - (wilds are not evaluated for this)

func (*TopicTree) SubscribersOf

func (tt *TopicTree) SubscribersOf(topic string) ([]*Client, error)

topic MUST be valid (ie no wild cards, no empty level, no ending slash)

Jump to

Keyboard shortcuts

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