Comments (2)
Good point. mqtt.Publish is the MQTT control packet data.
I modified the client APIs and now it looks as below. The parameters are more explicit in the API.
type Client interface {
// Connect connect with MQTT broker and send CONNECT MQTT request
Connect(ctx context.Context) (*ConnAck, error)
// Disconnect disconnect from MQTT broker
Disconnect(ctx context.Context, reasonCode DisconnectReasonCode, props *DisconnectProperties) error
// Subscribe send MQTT Subscribe request to the broker with the given Subscription parameter and it's
// properties, and a message channel through which the published messages are returned for the given
// subscribed topics.
// The function waits for the the MQTT SUBSCRIBE response, SubAck, or a packet timeout
// configured as part of the Client options
// Note: the subscriptions input may contain more than one topic, the associated
// MessageReceiver is valid for all the topics present in the given subscriptions.
Subscribe(ctx context.Context, subscriptions []*Subscription, props *SubscribeProperties, recvr *MessageReceiver) (*SubAck, error)
// CallbackSubscribe send MQTT Subscribe request to the broker with the given Subscription parameter and it's
// properties, and a callback handler through which the published messages are returned for the given subscribed topics.
// The function waits for the the MQTT SUBSCRIBE response, SubAck, or a packet timeout
// configured as part of the Client options
// Note: the input Subscribe parameter can contain more than one topic, the associated
// Callback handler is valid for all the topics present in the given Subscribe.
CallbackSubscribe(ctx context.Context, subscriptions []*Subscription, props *SubscribeProperties, cb MessageHandler) (*SubAck, error)
// Unsubscribe send MQTT UNSUBSCRIBE request to the broker with the given topic filters and it's properties.
// The function waits for the the MQTT SUBSCRIBE response, SubAck, or for a packet timeout
Unsubscribe(ctx context.Context, topicFilters []string, props *UnsubscribeProperties) (*UnsubAck, error)
// Publish send MQTT PUBLISH packet to the MQTT broker. When the QoS is 1 or 2
// the function waits for a response from the broker and for QoS 0 the function
// complets immediately after the PUBLISH message is scheduled to send.
Publish(ctx context.Context, topic string, qosLevel byte, retain bool, payload []byte, props *PublishProperties) error
// On map the callback argument with the event name, more than one
// callback can be added for a particular event name
On(eventName string, callback interface{}) error
// Off removed the callback associated with the event name
Off(eventName string, value interface{}) error
}
from mqtt.go.
merged
from mqtt.go.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mqtt.go.