Documentation ¶
Index ¶
- func NewDummyMessage(topic string, payload []byte) mqtt.Message
- type Publishment
- type Subscription
- type SubscriptionBase
- type TestClient
- func (t *TestClient) AddRoute(_ string, _ mqtt.MessageHandler)
- func (t *TestClient) AssertNumPublishments(testing *testing.T, num int)
- func (t *TestClient) AssertNumSubscriptions(testing *testing.T, num int)
- func (t *TestClient) AssertPublishments(testing *testing.T, offset int, topic string, qos byte, retained bool, ...)
- func (t *TestClient) AssertSubscription(testing *testing.T, offset int, topic string, qos byte)
- func (t *TestClient) Connect() mqtt.Token
- func (t *TestClient) Disconnect(_ uint)
- func (t *TestClient) GetPublishedPayload(offset int) interface{}
- func (t *TestClient) IsConnected() bool
- func (t *TestClient) IsConnectionOpen() bool
- func (t *TestClient) OptionsReader() mqtt.ClientOptionsReader
- func (t *TestClient) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token
- func (t *TestClient) Send(testing *testing.T, topic string, payload interface{})
- func (t *TestClient) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token
- func (t *TestClient) SubscribeMultiple(_ map[string]byte, _ mqtt.MessageHandler) mqtt.Token
- func (t *TestClient) Unsubscribe(_ ...string) mqtt.Token
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Publishment ¶
type Subscription ¶
type Subscription struct { SubscriptionBase Matcher *regexp.Regexp Callback mqtt.MessageHandler }
type SubscriptionBase ¶
type TestClient ¶
type TestClient struct { Publishments []Publishment Subscriptions []Subscription // contains filtered or unexported fields }
func NewTestClient ¶
func NewTestClient() TestClient
func (*TestClient) AddRoute ¶
func (t *TestClient) AddRoute(_ string, _ mqtt.MessageHandler)
AddRoute allows you to add a handler for messages on a specific topic without making a subscription. For example having a different handler for parts of a wildcard subscription
func (*TestClient) AssertNumPublishments ¶
func (t *TestClient) AssertNumPublishments(testing *testing.T, num int)
func (*TestClient) AssertNumSubscriptions ¶
func (t *TestClient) AssertNumSubscriptions(testing *testing.T, num int)
******
- Assertions
func (*TestClient) AssertPublishments ¶
func (*TestClient) AssertSubscription ¶
func (*TestClient) Connect ¶
func (t *TestClient) Connect() mqtt.Token
Connect will create a connection to the message broker, by default it will attempt to connect at v3.1.1 and auto retry at v3.1 if that fails
func (*TestClient) Disconnect ¶
func (t *TestClient) Disconnect(_ uint)
Disconnect will end the connection with the server, but not before waiting the specified number of milliseconds to wait for existing work to be completed.
func (*TestClient) GetPublishedPayload ¶
func (t *TestClient) GetPublishedPayload(offset int) interface{}
func (*TestClient) IsConnected ¶
func (t *TestClient) IsConnected() bool
IsConnected returns a bool signifying whether the client is connected or not.
func (*TestClient) IsConnectionOpen ¶
func (t *TestClient) IsConnectionOpen() bool
IsConnectionOpen return a bool signifying wether the client has an active connection to mqtt broker, i.e not in disconnected or reconnect mode
func (*TestClient) OptionsReader ¶
func (t *TestClient) OptionsReader() mqtt.ClientOptionsReader
OptionsReader returns a ClientOptionsReader which is a copy of the clientoptions in use by the client.
func (*TestClient) Publish ¶
Publish will publish a message with the specified QoS and content to the specified topic. Returns a token to track delivery of the message to the broker
func (*TestClient) Send ¶
func (t *TestClient) Send(testing *testing.T, topic string, payload interface{})
******
- Interaction
func (*TestClient) Subscribe ¶
func (t *TestClient) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token
func (*TestClient) SubscribeMultiple ¶
func (t *TestClient) SubscribeMultiple(_ map[string]byte, _ mqtt.MessageHandler) mqtt.Token
SubscribeMultiple starts a new subscription for multiple topics. Provide a MessageHandler to be executed when a message is published on one of the topics provided, or nil for the default handler
func (*TestClient) Unsubscribe ¶
func (t *TestClient) Unsubscribe(_ ...string) mqtt.Token
Unsubscribe will end the subscription from each of the topics provided. Messages published to those topics from other clients will no longer be received.