I am using C# Pubnub SDK. To interact with Pubnub I use Pubnub class. So what are the best practices of managing Pubnub object? I assume it is quite heavy. I don't want to create new object whenever I need to do something with Pubnub.
I have a Web application. Can I simply put Pubnub object into a static field and make it available from everywhere in the application? Are there any potential problems with it?
Currently I am using only HereNow pubnub function.
Andrei, you can re-use the object as needed for multiple calls. When you are done with it, to free memory, you can clean it up via the
EndPendingRequests()
method. More info on that here: https://github.com/pubnub/c-sharp/tree/master/csharp.net#object-cleanup
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