Documentation
¶
Index ¶
- Constants
- Variables
- type Instance
- func (i *Instance) Connect(ctx context.Context) (net.Conn, chan struct{}, error)
- func (i *Instance) Connected() bool
- func (i *Instance) SetConnectCallback(callback func(cp *packets.Connect, cap *packets.Connack))
- func (i *Instance) SetPacketReceivedCallback(callback func(publish *packets.ControlPacket) error)
- type Logger
- type MIDs
- type StateInfo
Constants ¶
const ( CloseOnPublishReceived = `CloseOnPublishReceived` // Disconnects when the `PUBLISH` message has been received (before any response) CloseOnPubAckReceived = `CloseOnPubAckReceived` // Disconnects when the `PUBACK` message has been received (before any response) CloseOnPubRecReceived = `CloseOnPubRecReceived` // Disconnects when the `PUBREC` message has been received (before any response) CloseOnPubRelReceived = `CloseOnPubRelReceived` // Disconnects when the `PUBREL` message has been received (before any response) CloseOnPubCompReceived = `CloseOnPubCompReceived` // Disconnects when the `PUBREL` message has been received (before any response) AppendAfterActionProcessed = `Done` // Appended to message body after action carried out (does not apply to Publish) )
Message bodies that trigger an action (note that after action completed `Done` will be appended)
Variables ¶
var ErrorMIDsExhausted = errors.New("all message ids in use")
ErrorMIDsExhausted is returned from Request() when there are no free message ids to be used.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance an instance of the test server Note that many variables are not mutex protected (because they are private and only accessed from one goroutine)
func (*Instance) Connect ¶
Connect establishes a connection to the test server Note that this can fail! Returns a net.Conn (to pass to paho), a channel that will be closed when connection has shutdown and an error (if any).
func (*Instance) Connected ¶
Connected returns true if the test server has an active connection with the client
func (*Instance) SetConnectCallback ¶
SetConnectCallback sets callback that will be called before the response to a CONNECT packet is sent. The CONNACK packet mak be altered if required. Note: this is not thread safe - call before sending any messages
func (*Instance) SetPacketReceivedCallback ¶
func (i *Instance) SetPacketReceivedCallback(callback func(publish *packets.ControlPacket) error)
SetPacketReceivedCallback sets callback that will be called whenever a packet is received If the callback returns an error the connection will be dropped Note: this is not thread safe - call before sending any messages
type Logger ¶
type Logger interface { Println(v ...interface{}) Printf(format string, v ...interface{}) }
Logger mirrors paho.Logger
type MIDs ¶
MIDs is a simple service to provide message IDs (mostly copied from paho)
type StateInfo ¶
type StateInfo struct { Sent *packets.ControlPacket // The most recent packet we sent with the relevant ID (will be resent on reconnection) // For publish related packets (included to simplify later operations) QOS byte // The QOS in the `PUBLISH` Topic string // The topic from the original `PUBLISH` (if applicable) Payload []byte // The payload from `PUBLISH` (or nil for other messages) }
StateInfo holds state information relating to a message ID
func NewStateInfo ¶
NewStateInfo creates a StateInfo