Rebuild docs to make them easier to maintain
This commit is contained in:
24
_posts/2000-10-02-callback.md
Normal file
24
_posts/2000-10-02-callback.md
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
tag: docs
|
||||
type: other
|
||||
title: Subscription Callback
|
||||
---
|
||||
|
||||
If the client is used to subscribe to topics, a callback function must be provided in the constructor. This function is called when new messages arrive at the client.
|
||||
|
||||
The callback function has the following signature:
|
||||
|
||||
void callback(const char[] topic, byte* payload, unsigned int length)
|
||||
|
||||
##### Parameters
|
||||
|
||||
- <span class="methodparams">topic</span> <span class="methodparamstype">const char[]</span> - the topic the message arrived on
|
||||
- <span class="methodparams">payload</span> <span class="methodparamstype">byte[]</span> - the message payload
|
||||
- <span class="methodparams">length</span> <span class="methodparamstype">unsigned int</span> - the length of the message payload
|
||||
|
||||
|
||||
Internally, the client uses the same buffer for both inbound and outbound
|
||||
messages. After the callback function returns, or if a call to either `publish`
|
||||
or subscribe is made from within the callback function, the `topic`
|
||||
and `payload` values passed to the function will be overwritten. The application
|
||||
should create its own copy of the values if they are required after the callback returns.
|
Reference in New Issue
Block a user