Documentation
¶
Index ¶
- Variables
- type Client
- func (cl *Client) ClearBuffers()
- func (cl *Client) ForgetSubscription(filter string)
- func (cl *Client) Identify(lid string, pk packets.Packet, ac auth.Controller)
- func (cl *Client) Info() events.Client
- func (cl *Client) NextPacketID() uint32
- func (cl *Client) NoteSubscription(filter string, qos byte)
- func (cl *Client) Read(packetHandler 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(err error)
- func (cl *Client) StopCause() error
- 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 is returned when operating on a closed // connection and/or when no error cause has been given. ErrConnectionClosed = errors.New("connection not open") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { State State // the operational state of the client. LWT LWT // the last will and testament for the client. Inflight *Inflight // a map of in-flight qos messages. sync.RWMutex // mutex Username []byte // the username the client authenticated with. AC auth.Controller // an auth controller inherited from the listener. Listener string // the id of the listener the client is connected to. ID string // the client id. R *circ.Reader // a reader for reading incoming bytes. W *circ.Writer // a writer for writing outgoing bytes. Subscriptions topics.Subscriptions // a map of the subscription filters a client maintains. CleanSession bool // indicates if the client expects a clean-session. // 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) ClearBuffers ¶ added in v1.2.0
func (cl *Client) ClearBuffers()
ClearBuffers sets the read/write buffers to nil so they can be deallocated automatically when no longer in use.
func (*Client) ForgetSubscription ¶
ForgetSubscription forgests a subscription note for the client.
func (*Client) Info ¶ added in v1.1.2
Info returns an event-version of a client, containing minimal information.
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) Read ¶
Read loops forever reading new packets from a client connection until an error is encountered (or the connection is closed).
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.
func (*Client) Stop ¶
Stop instructs the client to shut down all processing goroutines and disconnect. A cause error may be passed to identfy the reason for stopping.
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) ClearExpired ¶ added in v1.3.0
ClearExpired deletes any inflight messages that have remained longer than the servers InflightTTL duration. Returns number of deleted inflights.
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. Created int64 // the unix timestamp when the inflight message was created. 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 { Message []byte // the message that shall be sent when the client disconnects. Topic string // the topic the will message shall be sent to. 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.