I am writing a simple chat application using PubNub to demo realtime data. When the application starts it shows a list of connected users down the side. Each user has a default UUID that is generated by PubNub when initialised. I want to be able to change this UUID to something more human friendly. I am aware that I can do this when I initialise the PubNub library
PubNub.init({
... keys ...
uuid: 'The username'
});
But I wish to also do this 'on the fly' so users can update their username during the runtime of the application. I have not been able to find any documentation to support this functionality which suggests to me it is not possible. However I also see nothing stating it cannot be done. Is there such a feature and how do I do it?
You can change the UUID of a connected client anytime. Use the set_uuid method to update the UUID and have the SDK re-initialize the Connection State with a new UUID.
var pubnub = PUBNUB({ ..., uuid : "CLIENT_UUID" });
pubnub.set_uuid("NEW_UUID");
The only reference currently posted on PubNub Documentation is here: https://www.pubnub.com/docs/posix-cpp/api-reference#init_example_3 in the PubNub POSIX C API Reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With