Every OCStartPresence sends a random nonce.
C++ Stack cleanup to use unsigned integer for nonce.
Change-Id: If83e0868bbc05fa641cd3a0758e250b59da6393c
* presence notifications to clients via multicast. Once this API has been called with a success,
* clients may query for this server's presence and this server's stack will respond via multicast.
*
- * @param ttl (Time To Live in seconds) - Used to set the time a server
+ * Server can call this function when it comes online for the first time, or when it comes back
+ * online from offline mode, or when it re enters network.
+ *
+ * @param ttl - Time To Live in seconds
* Note: If ttl is '0', then the default stack value will be used (60 Seconds).
*
* @return
* OC_STACK_OK - No errors; Success
- * OC_STACK_ERROR - @ref OCStartPresence has already been called.
*/
OCStackResult OCStartPresence(const uint32_t ttl);
* presence notifications to clients via multicast. Once this API has been called with a success,
* this server's stack will not respond to clients querying for this server's presence.
*
+ * Server can call this function when it is terminating, going offline, or when going
+ * away from network.
+ *
* @return
* OC_STACK_OK - No errors; Success
- * OC_STACK_ERROR - @ref OCStartPresence has never been called or @ref OCStopPresence has
- * already been called.
*/
+
OCStackResult OCStopPresence();
#endif
/**
*
* @return
* OC_STACK_OK - No errors; Success
- * OC_STACK_ERROR - @ref OCStartPresence has already been called.
*/
OCStackResult OCStartPresence(const uint32_t ttl)
{
(OCResource *)presenceResource.handle, OC_NON_CONFIRMABLE);
}
+ // Each time OCStartPresence is called
+ // a different random 32-bit integer number is used
+ ((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
+
return OCNotifyObservers(presenceResource.handle);
}
*
* @return
* OC_STACK_OK - No errors; Success
- * OC_STACK_ERROR - @ref OCStartPresence has never been called or @ref OCStopPresence has
- * already been called.
*/
OCStackResult OCStopPresence()
{
result = OCChangeResourceProperty(
&(((OCResource *) presenceResource.handle)->resourceProperties),
OC_ACTIVE, 0);
- //initialize the sequence number as a random 32-bit integer
- ((OCResource *)presenceResource.handle)->sequenceNum = OCGetRandom();
#endif
return result;
}
OCPlatform* platformPtr;
// Callback to presence
-void presenceHandler(OCStackResult result, const int& nonce)
+void presenceHandler(OCStackResult result, const unsigned int nonce)
{
switch(result)
{
typedef std::function<void(std::shared_ptr<OCResource>)> FindCallback;
typedef std::function<void(const std::shared_ptr<OCResourceRequest>, const std::shared_ptr<OCResourceResponse>)> RegisterCallback;
- typedef std::function<void(OCStackResult, const int)> SubscribeCallback;
+ typedef std::function<void(OCStackResult, const unsigned int)> SubscribeCallback;
typedef std::function<void(const OCRepresentation&, const int)> GetCallback;
typedef std::function<void(const OCRepresentation&, const int)> PutCallback;
typedef std::function<void(const OCRepresentation&, const int, const int)> ObserveCallback;