Microservices - Distributing
Create and deploy server-authoritative C# [CLCP-Microservices-08]
The purpose of this guide is for game makers to distribute server-authoritative C# functionality via Beamable Microservices.
Distribution
- Game makers can distribute the Microservice internally within their organization and share it across several game projects
- Or distribute the Microservice publicly for use by the community
Game Maker User Experience
During development, the game maker's user experience is as follows: There are 3 major parts to the process.
Steps
Follow these steps to get started:
Step 1. Setup Microservice
Name | Detail |
---|---|
| • See Adding Microservices for more info Note: Ensure that Microservice development is complete before continuing |
Step 2. Package Microservice
Work within the same project created in Step 1 above.
Name | Detail |
---|---|
| Note: This Unity project will be the source of the Unity custom package |
| • See Unity's docs.unity3d.com/Manual/CustomPackages.html for more info |
| • Ex. Github.com |
| • See Unity's Docs.unity3d.com/Manual/cus-share.html for more info Note: There are several options. For this example, Beamable uses the |
Step 3. Import Microservice
Name | Detail |
---|---|
| Note: This Unity project will be the destination, where the Unity custom package will be used |
| ![]() ![]() *Note: There are several options. For this example, Beamable uses the `Via Git URL` solution with a url of `https://github.com/beamable/Microservices-TimedRewards.git`* |
Example
Here are examples which cover common programming needs.
Beamable SDK Examples
• Source Unity Project - Github.com/beamable/Microservices-TimedRewards
• Destination Unity Project - Github.com/beamable/Beamable_Microservices_Examples
Source - Microservices TimedRewards
This demonstrates;
- How to create a Unity custom package as a Microservice
- And its a production-ready Microservice which adds a "Timed Rewards" feature
Destination - Beamable Microservices Examples
This demonstrates;
- How to import a Unity custom package as a Microservice
- And its an example usage of the "Timed Rewards" feature
Code
Here are examples which cover common programming needs.
The TimedRewardsMicroserviceExample.cs
demonstrates the custom code added to the destination project to properly consume the imported source project.
using UnityEngine;
using Beamable.Server.Clients;
namespace Beamable.Examples.Features.Microservices.TimedRewardsMicroserviceExample
{
/// <summary>
/// Demonstrates <see cref="Microservices"/>.
/// </summary>
public class TimedRewardsMicroserviceExample : MonoBehaviour
{
// Properties -----------------------------------
// Fields ---------------------------------------
[SerializeField]
private TimeRewardRef _timeRewardRef = null;
private TimedRewardServiceClient _timedRewardServiceClient;
// Unity Methods --------------------------------
protected void Start()
{
Debug.Log("Start() Instructions...\n" +
"* Complete docker setup per https://docs.beamable.com/docs/microservices-feature\n" +
"* Start the server per https://docs.beamable.com/docs/microservices-feature\n" +
"* Play This Scene\n" +
"* Enjoy!\n\n\n");
SetupBeamable();
}
// Methods --------------------------------------
private async void SetupBeamable()
{
var beamableAPI = await Beamable.API.Instance;
Debug.Log($"beamableAPI.User.id = {beamableAPI.User.id}");
_timedRewardServiceClient = new TimedRewardServiceClient();
// #1 - Call Microservice
bool isSuccess = await _timedRewardServiceClient.Claim(_timeRewardRef);
// #2 - Result = true
Debug.Log ($"AddMyValues() isSuccess = {isSuccess}");
}
}
}
Advanced
This section contains any advanced configuration options and workflows.
Updated 5 months ago