Documentation ¶
Index ¶
- Constants
- func CallbackRegister(pluginID PluginID, event Event, cb interface{}, eventData interface{}) error
- func CallbackUnregister(pluginID PluginID, event Event, cb interface{}, eventData interface{}) error
- func KickClientByClientID(clientID string, withWill bool) int
- func KickClientByUsername(username string, withWill bool) int
- func Publish(clientID, topic string, payload []byte, qos int, retain bool) error
- func RegisterPlugin(p Plugin)
- func TopicMatchesSub(topic, subscription string) bool
- type Access
- type Client
- func (c Client) Address() string
- func (c Client) CleanSession() bool
- func (c Client) ClientID() string
- func (c Client) KeepAlive() int
- func (c Client) Protocol() Protocol
- func (c Client) ProtocolVersion() ProtocolVersion
- func (c Client) SetUsername(name string) error
- func (c Client) SubscriptionCount() int
- func (c Client) Username() string
- type Error
- type Event
- type EvtAclCheck
- type EvtBasicAuth
- type EvtControl
- type EvtDisconnect
- type EvtExtendedAuth
- type EvtMessage
- func (e EvtMessage) Client() Client
- func (e EvtMessage) Payload() []byte
- func (e EvtMessage) QoS() int
- func (e EvtMessage) Retained() bool
- func (e EvtMessage) SetPayload(data []byte)
- func (e EvtMessage) SetQoS(qos int)
- func (e EvtMessage) SetRetained(retain bool)
- func (e EvtMessage) SetTopic(topic string)
- func (e EvtMessage) Topic() string
- type EvtPskKey
- type EvtReload
- type EvtTick
- type Options
- type Plugin
- type PluginID
- type Protocol
- type ProtocolVersion
Constants ¶
const ( MosqAclNone = Access(C.MOSQ_ACL_NONE) MosqAclRead = Access(C.MOSQ_ACL_READ) MosqAclWrite = Access(C.MOSQ_ACL_WRITE) MosqAclSubscribe = Access(C.MOSQ_ACL_SUBSCRIBE) MosqAclUnsubscribe = Access(C.MOSQ_ACL_UNSUBSCRIBE) )
const ( MosqErrAuthContinue = Error(C.MOSQ_ERR_AUTH_CONTINUE) MosqErrNoSubscribers = Error(C.MOSQ_ERR_NO_SUBSCRIBERS) MosqErrSubExists = Error(C.MOSQ_ERR_SUB_EXISTS) MosqErrConnPending = Error(C.MOSQ_ERR_CONN_PENDING) MosqErrSuccess = Error(C.MOSQ_ERR_SUCCESS) MosqErrNoMem = Error(C.MOSQ_ERR_NOMEM) MosqErrProtocol = Error(C.MOSQ_ERR_PROTOCOL) MosqErrInval = Error(C.MOSQ_ERR_INVAL) MosqErrNoConn = Error(C.MOSQ_ERR_NO_CONN) MosqErrConnRefused = Error(C.MOSQ_ERR_CONN_REFUSED) MosqErrNotFound = Error(C.MOSQ_ERR_NOT_FOUND) MosqErrConnLost = Error(C.MOSQ_ERR_CONN_LOST) MosqErrTLS = Error(C.MOSQ_ERR_TLS) MosqErrPayloadSize = Error(C.MOSQ_ERR_PAYLOAD_SIZE) MosqErrNotSupported = Error(C.MOSQ_ERR_NOT_SUPPORTED) MosqErrAuth = Error(C.MOSQ_ERR_AUTH) MosqErrACLDenied = Error(C.MOSQ_ERR_ACL_DENIED) MosqErrUnknown = Error(C.MOSQ_ERR_UNKNOWN) MosqErrErrno = Error(C.MOSQ_ERR_ERRNO) MosqErrEAI = Error(C.MOSQ_ERR_EAI) MosqErrProxy = Error(C.MOSQ_ERR_PROXY) MosqErrPluginDefer = Error(C.MOSQ_ERR_PLUGIN_DEFER) MosqErrMalformedUTF8 = Error(C.MOSQ_ERR_MALFORMED_UTF8) MosqErrKeepAlive = Error(C.MOSQ_ERR_KEEPALIVE) MosqErrLookup = Error(C.MOSQ_ERR_LOOKUP) MosqErrMalformedPacket = Error(C.MOSQ_ERR_MALFORMED_PACKET) MosqErrDuplicateProperty = Error(C.MOSQ_ERR_DUPLICATE_PROPERTY) MosqErrTLSHandshake = Error(C.MOSQ_ERR_TLS_HANDSHAKE) MosqErrQOSNotSupported = Error(C.MOSQ_ERR_QOS_NOT_SUPPORTED) MosqErrOversizePacket = Error(C.MOSQ_ERR_OVERSIZE_PACKET) MosqErrOCSP = Error(C.MOSQ_ERR_OCSP) MosqErrTimeout = Error(C.MOSQ_ERR_TIMEOUT) MosqErrRetainNotSupported = Error(C.MOSQ_ERR_RETAIN_NOT_SUPPORTED) MosqErrTopicAliasInvalid = Error(C.MOSQ_ERR_TOPIC_ALIAS_INVALID) MosqErrAdministrativeAction = Error(C.MOSQ_ERR_ADMINISTRATIVE_ACTION) MosqErrAlreadyExists = Error(C.MOSQ_ERR_ALREADY_EXISTS) )
Errors from mosquitto.h
const ( MosqEvtReload = Event(C.MOSQ_EVT_RELOAD) MosqEvtACLCheck = Event(C.MOSQ_EVT_ACL_CHECK) MosqEvtBasicAuth = Event(C.MOSQ_EVT_BASIC_AUTH) MosqEvtEXTAuthStart = Event(C.MOSQ_EVT_EXT_AUTH_START) MosqEvtEXTAuthContinue = Event(C.MOSQ_EVT_EXT_AUTH_CONTINUE) MosqEvtControl = Event(C.MOSQ_EVT_CONTROL) MosqEvtMessage = Event(C.MOSQ_EVT_MESSAGE) MosqEvtPSKKey = Event(C.MOSQ_EVT_PSK_KEY) MosqEvtTick = Event(C.MOSQ_EVT_TICK) MosqEvtDisconnect = Event(C.MOSQ_EVT_DISCONNECT) )
const ( ProtocolMQTT = Protocol(C.mp_mqtt) ProtocolMQTTSN = Protocol(C.mp_mqttsn) ProtocolMQTTWebsockets = Protocol(C.mp_websockets) )
const ( MQTTProtocolV31 = ProtocolVersion(C.MQTT_PROTOCOL_V31) MQTTProtocolV311 = ProtocolVersion(C.MQTT_PROTOCOL_V311) MQTTProtocolV5 = ProtocolVersion(C.MQTT_PROTOCOL_V5) )
const (
MosqPluginVersion = C.MOSQ_PLUGIN_VERSION
)
Variables ¶
This section is empty.
Functions ¶
func CallbackRegister ¶
CallbackRegister * Register a callback for an event. * * Parameters: * pluginID - the plugin identifier, as provided by <mosquitto_plugin_init>. * event - the event to register a callback for. Can be one of: * * MosqEvtReload * * MosqEvtACLCheck * * MosqEvtBasicAuth * * MosqEvtEXTAuthStart * * MosqEvtEXTAuthContinue * * MosqEvtControl * * MosqEvtMessage * * MosqEvtPSKKey * * MosqEvtTick * * MosqEvtDisconnect * cb - the callback function * eventData - event specific data * * Returns: * nil - on success * MosqErrInval - if cb_func is NULL * MosqErrAlreadyExists - if cb_func has already been registered for this event * MosqErrNotSupported - if the event is not supported
func CallbackUnregister ¶
func CallbackUnregister(pluginID PluginID, event Event, cb interface{}, eventData interface{}) error
CallbackUnregister * Unregister a previously registered callback function. * * Parameters: * pluginID - the plugin identifier, as provided by <mosquitto_plugin_init>. * event - the event to register a callback for. Can be one of: * * MosqEvtReload * * MosqEvtACLCheck * * MosqEvtBasicAuth * * MosqEvtEXTAuthStart * * MosqEvtEXTAuthContinue * * MosqEvtControl * * MosqEvtMessage * * MosqEvtPSKKey * * MosqEvtTick * * MosqEvtDisconnect * cb - the callback function * eventData - event specific data * * Returns: * nil - on success * MosqErrInval - if cb_func is NULL * MosqErrNotFound - if cb_func was not registered for this event * MosqErrNotSupported - if the event is not supported
func KickClientByClientID ¶
KickClientByClientID * Forcefully disconnect a client from the broker. * * If clientid != "", then the client with the matching client id is * disconnected from the broker. * If clientid == "", then all clients are disconnected from the broker. * * If with_will == true, then if the client has a Last Will and Testament * defined then this will be sent. If false, the LWT will not be sent.
func KickClientByUsername ¶
KickClientByUsername * Forcefully disconnect a client from the broker. * * If username != "", then all clients with a matching username are kicked * from the broker. * If username == "", then all clients that do not have a username are * kicked. * * If with_will == true, then if the client has a Last Will and Testament * defined then this will be sent. If false, the LWT will not be sent.
func Publish ¶
Publish * Publish a message from within a plugin. * * This function allows a plugin to publish a message. Messages published in * this way are treated as coming from the broker and so will not be passed to * `mosquitto_auth_acl_check(, MOSQ_ACL_WRITE, , )` for checking. Read access * will be enforced as normal for individual clients when they are due to * receive the message. * * It can be used to send messages to all clients that have a matching * subscription, or to a single client whether or not it has a matching * subscription. * * Parameters: * clientID - optional string. If set to "", the message is delivered to all * clients. If non-empty, the message is delivered only to the * client with the corresponding client id. If the client id * specified is not connected, the message will be dropped. * topic - message topic. * payload - payload bytes. * qos - message QoS to use. * retain - should retain be set on the message. This does not apply if * clientid is non-NULL. * properties - MQTT v5 properties to attach to the message. If the function * returns success, then properties is owned by the broker and * will be freed at a later point. * * Returns: * nil - on success * MosqErrInval - if topic is NULL, if payloadlen < 0, if payloadlen > 0 * and payload is NULL, if qos is not 0, 1, or 2.
func RegisterPlugin ¶
func RegisterPlugin(p Plugin)
RegisterPlugin must be called in an init function in the plugin.
func TopicMatchesSub ¶
TopicMatchesSub * Check whether a topic matches a subscription. * * For example: * * foo/bar would match the subscription foo/# or +/bar * non/matching would not match the subscription non/+/+ * * Parameters: * topic - topic to check. * subscription - subscription string to check topic against. * * Returns: * true - if topic matches subscription * false - if topic doesn't match subscription, or if invalid parameters
Types ¶
type Client ¶
type Client uintptr
func (Client) CleanSession ¶
func (Client) ProtocolVersion ¶
func (c Client) ProtocolVersion() ProtocolVersion
func (Client) SetUsername ¶
func (Client) SubscriptionCount ¶
type EvtAclCheck ¶
type EvtAclCheck uintptr
func (EvtAclCheck) Access ¶
func (e EvtAclCheck) Access() Access
func (EvtAclCheck) Payload ¶
func (e EvtAclCheck) Payload() []byte
func (EvtAclCheck) QoS ¶
func (e EvtAclCheck) QoS() int
func (EvtAclCheck) Retained ¶
func (e EvtAclCheck) Retained() bool
func (EvtAclCheck) Topic ¶
func (e EvtAclCheck) Topic() string
type EvtBasicAuth ¶
type EvtBasicAuth uintptr
func (EvtBasicAuth) Client ¶
func (e EvtBasicAuth) Client() Client
func (EvtBasicAuth) Password ¶
func (e EvtBasicAuth) Password() string
type EvtControl ¶
type EvtControl uintptr
func (EvtControl) Payload ¶
func (e EvtControl) Payload() []byte
func (EvtControl) QoS ¶
func (e EvtControl) QoS() int
func (EvtControl) Retained ¶
func (e EvtControl) Retained() bool
func (EvtControl) Topic ¶
func (e EvtControl) Topic() string
type EvtDisconnect ¶
type EvtDisconnect uintptr
type EvtExtendedAuth ¶
type EvtExtendedAuth uintptr
type EvtMessage ¶
type EvtMessage uintptr
func (EvtMessage) Payload ¶
func (e EvtMessage) Payload() []byte
func (EvtMessage) QoS ¶
func (e EvtMessage) QoS() int
func (EvtMessage) Retained ¶
func (e EvtMessage) Retained() bool
func (EvtMessage) SetPayload ¶
func (e EvtMessage) SetPayload(data []byte)
func (EvtMessage) SetQoS ¶
func (e EvtMessage) SetQoS(qos int)
func (EvtMessage) SetRetained ¶
func (e EvtMessage) SetRetained(retain bool)
func (EvtMessage) SetTopic ¶
func (e EvtMessage) SetTopic(topic string)
func (EvtMessage) Topic ¶
func (e EvtMessage) Topic() string
type ProtocolVersion ¶
type ProtocolVersion int
func (ProtocolVersion) String ¶
func (p ProtocolVersion) String() string