publish final code
Dependencies: Pubnub_c_core_mbed2_pal2
Fork of Pubnub_mbed2_sync by
srand_from_pubnub_time.h@4:3ee9629861ab, 2017-02-21 (annotated)
- Committer:
- cswiger
- Date:
- Tue Feb 21 22:26:52 2017 +0000
- Revision:
- 4:3ee9629861ab
- Parent:
- 2:4d49720c7200
publish final code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sveljko | 2:4d49720c7200 | 1 | #if !defined INC_SRAND_FROM_PUBNUB_TIME |
sveljko | 2:4d49720c7200 | 2 | #define INC_SRAND_FROM_PUBNUB_TIME |
sveljko | 2:4d49720c7200 | 3 | |
sveljko | 2:4d49720c7200 | 4 | |
sveljko | 2:4d49720c7200 | 5 | #include "pubnub_api_types.h" |
sveljko | 2:4d49720c7200 | 6 | |
sveljko | 2:4d49720c7200 | 7 | |
sveljko | 2:4d49720c7200 | 8 | /** This helper function will call the C standard srand() function with the seed |
sveljko | 2:4d49720c7200 | 9 | taken from the time returned from Pubnub's `time` operation (which can |
sveljko | 2:4d49720c7200 | 10 | be initiated with pubnub_time()). |
sveljko | 2:4d49720c7200 | 11 | |
sveljko | 2:4d49720c7200 | 12 | It's useful if you want a high-fidelity time used for srand() and on |
sveljko | 2:4d49720c7200 | 13 | embedded system that don't have a Real-Time Clock. |
sveljko | 2:4d49720c7200 | 14 | |
sveljko | 2:4d49720c7200 | 15 | Keep in mind that this requires a round-trip to Pubnub, so it will take |
sveljko | 2:4d49720c7200 | 16 | some time, depending on your network, at least miliseconds. So, it's best |
sveljko | 2:4d49720c7200 | 17 | used only once, at the start of your program. |
sveljko | 2:4d49720c7200 | 18 | |
sveljko | 2:4d49720c7200 | 19 | @param pbp The Pubnub context to use to get time |
sveljko | 2:4d49720c7200 | 20 | @return 0: OK, -1: error (srand() was not called) |
sveljko | 2:4d49720c7200 | 21 | */ |
sveljko | 2:4d49720c7200 | 22 | int srand_from_pubnub_time(pubnub_t *pbp); |
sveljko | 2:4d49720c7200 | 23 | |
sveljko | 2:4d49720c7200 | 24 | |
sveljko | 2:4d49720c7200 | 25 | #endif /* !defined INC_SRAND_FROM_PUBNUB_TIME */ |