The 4.0 client libraries bring a bunch of new features:
- A new Relay Service that allows clients to talk directly to our new Relay Servers (Unity and Unreal-only)
- Enhancements to the existing Authentication, GlobalEntity, Identity, Lobby, and VirtualCurrency APIs
- Unreal Libs updated to better support Android and Unreal Engine 4.22
In addition, this being a dot-oh release, we are taking the opportunity to clean up the client libraries a bit.
As a result, there are a few breaking changes in the 4.0 libs. Here’s the list:
- Removed the deprecated singleton mode
- Refactored the RTT Event registration methods, introducing a new RTT Service to the client
- [Unity; C#] Wrapped all 3rd party libraries within a brainCloud namespace, so that they no longer conflict with unwrapped libraries from other sources (we’re looking at you Photon!)
- [Unity] Renamed the brainCloud Settings plugin (and associated class)
Further details on these changes below.
Singleton Mode has been removed
This is the biggest change — but most of you aren’t using it anyway.
For some background on the old singleton mode, why it’s evil, and how to move away from it — check out our post on Wrappers, Clients and Inconvenient Singletons.
Refactored RTT Registration
As we were reviewing 4.0, we realized that we had goofed when adding the RTT event registration methods to the client libraries. We’d put them directly in the root Client service, instead of in a proper RTT service.
(Note — these are calls like
Now that we are taking RTT out of beta, we thought we should address this error. The good news is that the fix to your code is super-simple:
// Old code
_bc.EnableRTT(rttConnectionType, successCallback, failureCallback);// New code
_bc.RTTService.EnableRTT(rttConnectionType, successCallback, failureCallback);
Wrapped Libraries in Unity / C#
The final change is how we handle embedded libraries in our C# libraries. brainCloud makes use of the following two libraries:
The problem is that developers sometimes will see conflicts if they also inherit these libs from another 3rd party plug-in or library.
The solution up-until-now has been to simply delete one of the libraries — but that is a pain since you have to remember to delete it again each and every time you update your libraries.
So — we’ve wrapped these libraries in a
BrainCloud namespace so that they don’t conflict anymore.
But Paul — this seems like an internal change. Why would it affect me?
Answer: Because many of our clients also use the JsonFx or LitJson libraries directly in their apps. Which is of course fine. But if you do, you need to make a small change to how you reference those libraries.
// Old code
using JsonFx.Json;// New code
Renamed the brainCloud Settings Plug-in in Unity
We have done some refactoring of the Unity plugin.
To accomodate, you first need to declare your dependencies differently:
// Old code
using BrainCloudUnity.BrainCloudPlugin;// New code
And then, if you want to access the plugin’s settings, use the BaseBrainCloudSettings class now (instead of the old BrainCloudPluginSettings class).
// Old code
id = BrainCloudPluginSettings.DEFAULT_TEMPLATE_ID_KEY// New code
id = BaseBrainCloudSettings.DEFAULT_TEMPLATE_ID_KEY
Anyway, that’s the deal. If you aren’t using our old singletons, these changes should take just 5–10 minutes to incorporate into your app.
If you are using singletons — you are looking at a few hours?
Oh — and it goes without saying, that the old client libraries continue to work with brainCloud for the foreseeable future. But really, there are tons of new features and fixes in the new libs — do everyone a favor and upgrade!