Documentation ¶
Index ¶
- Constants
- Variables
- func Head(b0 byte, length int, total int) ([]byte, []byte)
- func Join(conn net.Conn, server *Server)
- func ListenAndServe(addr string, handler Handler) error
- type Context
- func (ctx *Context) Alive() bool
- func (ctx *Context) Close() error
- func (ctx *Context) ConnAck(code byte)
- func (ctx *Context) Fail(err error) error
- func (ctx *Context) Failf(format string, a ...interface{}) error
- func (ctx *Context) Get(key string) interface{}
- func (ctx *Context) PingResp()
- func (ctx *Context) Publish(sub *Subscription, msg *Message)
- func (ctx *Context) Read(reader io.Reader)
- func (ctx *Context) ReadConnectMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) ReadPubcompMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) ReadPublishMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) ReadPubrecMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) ReadPubrelMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) ReadSubscribeMessage(reader io.Reader, fh *FixedHeader, buf []byte)
- func (ctx *Context) Set(key string, value interface{})
- func (ctx *Context) Subscribe(topic string, qos byte) byte
- func (ctx *Context) Unsubscribe(topic string)
- func (ctx *Context) Write(data []byte) (n int, err error)
- type FixedHeader
- type Handler
- type Message
- type Publisher
- type Server
- func (svr *Server) Alive() bool
- func (svr *Server) Close()
- func (svr *Server) Publish(ctx *Context, msg *Message)
- func (svr *Server) Run()
- func (svr *Server) Serve(rwc io.ReadWriteCloser)
- func (svr *Server) Subscribe(ctx *Context, topic string, qos byte) *Subscription
- func (svr *Server) Unsubscribe(subs *Subscription)
- type Subscription
- type SubscriptionChange
- type SubscriptionHandler
- type SubscriptionRequest
- type Topic
- func (topic *Topic) Enqueue(queue **Subscription, s *Subscription)
- func (topic *Topic) Find(s []string) *Subscription
- func (topic *Topic) PrintIndent(builder *strings.Builder, indent string)
- func (topic *Topic) Publish(s []string, msg *Message)
- func (topic *Topic) Remove()
- func (topic *Topic) String() string
- func (topic *Topic) Subscribe(t []string, sub *Subscription)
Constants ¶
View Source
const ( CONNECTING = 0 CONNECTED = 1 CLOSING = 3 CLOSED = 4 )
View Source
const ( ACCEPTED = 0 UNACCEPTABLE_PROTOV = 1 IDENTIFIER_REJ = 2 SERVER_UNAVAIL = 3 BAD_USER_OR_PASS = 4 NOT_AUTHORIZED = 5 )
CONNACK return codes
View Source
const ( CONNECT = 1 CONNACK = 2 PUBLISH = 3 PUBACK = 4 PUBREC = 5 PUBREL = 6 PUBCOMP = 7 SUBSCRIBE = 8 SUBACK = 9 UNSUBSCRIBE = 10 UNSUBACK = 11 PINGREQ = 12 PINGRESP = 13 DISCONNECT = 14 )
message types
View Source
const ( CREATE = 1 REMOVE = 2 )
Variables ¶
View Source
var ( InclompleteHeader = errors.New("incomplete header") MaxMessageLength = errors.New("message length exceeds server maximum") MessageLengthInvalid = errors.New("message length exceeds maximum") IncompleteMessage = errors.New("incomplete message") UnknownMessageType = errors.New("unknown mqtt message type") ReservedMessageType = errors.New("reserved message type") ConnectMsgLacksProtocol = errors.New("connect message has no protocol field") ConnectProtocolUnexp = errors.New("connect message protocol is not 'MQIsdp'") TooLongClientID = errors.New("connect client id is too long") UnknownMessageID = errors.New("unknown message id") )
errors
Functions ¶
func ListenAndServe ¶
Types ¶
type Context ¶
type Context struct { // server *Server ClientID string Will *Message // contains filtered or unexported fields }
func (*Context) Publish ¶
func (ctx *Context) Publish(sub *Subscription, msg *Message)
func (*Context) ReadConnectMessage ¶
func (ctx *Context) ReadConnectMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse CONNECT messages
func (*Context) ReadPubcompMessage ¶
func (ctx *Context) ReadPubcompMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse a PUBCOMP message (a response to a PUBREL from a client to this server)
func (*Context) ReadPublishMessage ¶
func (ctx *Context) ReadPublishMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse a PUBLISH message and tell the server about it
func (*Context) ReadPubrecMessage ¶
func (ctx *Context) ReadPubrecMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse a PUBREC message (a response to a publish from this server to a client on qos 2)
func (*Context) ReadPubrelMessage ¶
func (ctx *Context) ReadPubrelMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse a PUBREL message (a response to a PUBREC at QoS 2) the message has alredy been stored at the previous PUBREC message
func (*Context) ReadSubscribeMessage ¶
func (ctx *Context) ReadSubscribeMessage(reader io.Reader, fh *FixedHeader, buf []byte)
parse a SUBSCRIBE message and send SUBACK
func (*Context) Unsubscribe ¶
type FixedHeader ¶
type FixedHeader struct {
// contains filtered or unexported fields
}
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Serve ¶
func (svr *Server) Serve(rwc io.ReadWriteCloser)
func (*Server) Subscribe ¶
func (svr *Server) Subscribe(ctx *Context, topic string, qos byte) *Subscription
func (*Server) Unsubscribe ¶
func (svr *Server) Unsubscribe(subs *Subscription)
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func NewSubscription ¶
func NewSubscription(ctx *Context, qos byte) *Subscription
func (*Subscription) ChainLength ¶
func (s *Subscription) ChainLength() int
func (*Subscription) Publish ¶
func (s *Subscription) Publish(msg *Message)
func (*Subscription) Unsubscribe ¶
func (sub *Subscription) Unsubscribe()
type SubscriptionChange ¶
type SubscriptionChange struct {
// contains filtered or unexported fields
}
type SubscriptionHandler ¶
type SubscriptionHandler interface { Subscribe(ctx *Context, topic string, qos byte) *Subscription Unsubscribe(subs *Subscription) }
type SubscriptionRequest ¶
type SubscriptionRequest struct {
// contains filtered or unexported fields
}
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
func (*Topic) Enqueue ¶
func (topic *Topic) Enqueue(queue **Subscription, s *Subscription)
func (*Topic) Find ¶
func (topic *Topic) Find(s []string) *Subscription
func (*Topic) PrintIndent ¶
func (*Topic) Subscribe ¶
func (topic *Topic) Subscribe(t []string, sub *Subscription)
Click to show internal directories.
Click to hide internal directories.