mmehr2 / Msw4

Source code for MagicScroll for Windows (basic) project.
0 stars 0 forks source link

Use of UUIDs/devices in Pubnub #11

Closed mmehr2 closed 6 years ago

mmehr2 commented 6 years ago

Pubnub counts (and bills) Daily Device usage. Free Tier is allowed 100 of these on any given day (500 for the Starter Tier paid one). These are intended to be one per device connection. It's unclear if the automatic operation of the library creates a new one every time the code first uses the library, or when. Then we need to see if it makes sense to add code to generate one, save it in the INI file, and reuse it for every initialization sequence (or MSW startup, at least).

mmehr2 commented 6 years ago

Reply back from Vladamir was ambiguous, so I asked for clarification.

I suspect the answer is to do as stated, assign a device UUID once, using their generators (pick one). And then save it in the INI file, if it is found that one doesn't exist.

Will have to experiment with usage stats if I can't get an answer.

mmehr2 commented 6 years ago

Reply seems to indicate that yes, we can cut down on any ambiguity by creating something permanent as a UUID. Doesn't have to be GUID-compatible, any string will do. Such as the DeviceName already in the INI file.

mmehr2 commented 6 years ago

I managed to fix this with simple code to generate and save this in the INI file. I used the Pubnub API generate_v4_random() version.

I also discovered a bug in the documentation (all of it in many places) about the return value. Code samples all show that the function returns != 0 for success, but actually it returns 0, and -1 on failure.

Now there will be one UUID saved for each device in its INI file that will only change if the user deletes that line.