Documentation ¶
Index ¶
- Variables
- type Client
- func (cl *Client) ForgetSubscription(filter string)
- func (cl *Client) Identify(lid string, pk packets.Packet, ac auth.Controller)
- func (cl *Client) NextPacketID() uint32
- func (cl *Client) NoteSubscription(filter string, qos byte)
- func (cl *Client) Read(h func(*Client, packets.Packet) error) error
- func (cl *Client) ReadFixedHeader(fh *packets.FixedHeader) error
- func (cl *Client) ReadPacket(fh *packets.FixedHeader) (pk packets.Packet, err error)
- func (cl *Client) Start()
- func (cl *Client) Stop()
- func (cl *Client) WritePacket(pk packets.Packet) (n int, err error)
- type Clients
- type Inflight
- type InflightMessage
- type LWT
- type State
Constants ¶
This section is empty.
Variables ¶
var (
ErrConnectionClosed = errors.New("Connection not open")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { sync.RWMutex ID string // the client id. AC auth.Controller // an auth controller inherited from the listener. Subscriptions topics.Subscriptions // a map of the subscription filters a client maintains. Listener string // the id of the listener the client is connected to. Inflight Inflight // a map of in-flight qos messages. Username []byte // the username the client authenticated with. LWT LWT // the last will and testament for the client. State State // the operational state of the client. // contains filtered or unexported fields }
Client contains information about a client known by the broker.
func NewClientStub ¶
NewClientStub returns an instance of Client with basic initializations. This method is typically called by the persistence restoration system.
func (*Client) ForgetSubscription ¶
ForgetSubscription forgests a subscription note for the client.
func (*Client) NextPacketID ¶
NextPacketID returns the next packet id for a client, looping back to 0 if the maximum ID has been reached.
func (*Client) NoteSubscription ¶
NoteSubscription makes a note of a subscription for the client.
func (*Client) ReadFixedHeader ¶
func (cl *Client) ReadFixedHeader(fh *packets.FixedHeader) error
readFixedHeader reads in the values of the next packet's fixed header.
func (*Client) ReadPacket ¶
ReadPacket reads the remaining buffer into an MQTT packet.
func (*Client) Start ¶
func (cl *Client) Start()
Start begins the client goroutines reading and writing packets.
type Clients ¶
Clients contains a map of the clients known by the broker.
func (*Clients) GetByListener ¶
GetByListener returns clients matching a listener id.
type Inflight ¶
Inflight is a map of InflightMessage keyed on packet id.
func (*Inflight) Delete ¶
Delete removes an in-flight message from the map. Returns true if the message existed.
func (*Inflight) Get ¶
func (i *Inflight) Get(key uint16) (InflightMessage, bool)
Get returns the value of an in-flight message if it exists.
func (*Inflight) GetAll ¶
func (i *Inflight) GetAll() map[uint16]InflightMessage
GetAll returns all the in-flight messages.
type InflightMessage ¶
type InflightMessage struct { Packet packets.Packet // the packet currently in-flight. Sent int64 // the last time the message was sent (for retries) in unixtime. Resends int // the number of times the message was attempted to be sent. }
InflightMessage contains data about a packet which is currently in-flight.
type LWT ¶
type LWT struct { Topic string // the topic the will message shall be sent to. Message []byte // the message that shall be sent when the client disconnects. Qos byte // the quality of service desired. Retain bool // indicates whether the will message should be retained }
LWT contains the last will and testament details for a client connection.