Beamable Microservice

When Beamable is active, all calls, that require authentication, made with Venly's APIs are bridged to a Beamable Microservice. The following section will guide you through the process of creating and configuring such a Microservice.

Beamable CLI

The Beamable CLI is a dotnet tool that allows developers to interact with Beamable via the CLI. It can be used to manage Beamable Content, and Microservices, as well as make arbitrary requests to the Beamable backend.

Follow the instructions to install the Beamable CLI.

We can now use the Beamable CLI to create a new microservice (separate project) and link it with a UE Project.

Follow the instructions to create and link a new Beamable Microservice.

📘

The VenlySDK_UE_Beamable project on GitHub used the following values:

MicroservicesApp

VenlyProviderService

VenlySDK_UE_Beamable_MicroservicesBP (UncookedOnly)

Microservice Logic

If everything is properly configured, we should now have a separate C# project containing our Microservice logic. Next to that, it should be linked with our UE project, and generate an interface to invoke the Microservice from inside UE. (Files are generated after compiling the Microservice code)

After opening the Microservice Project you should see some 'template' code that looks similar to the following snippet:

using Beamable.Server;

namespace Beamable.VenlyProviderService
{
	[Microservice("VenlyProviderService")]
	public class VenlyProviderService : Microservice
	{
		[ClientCallable]
		public int Add(int a, int b)
		{
			return a + b;
		}
	}
}

Venly-Beamable Companion Assembly

We want to replace this with our logic, but before we do that we have to make sure to add the Venly-Beamable Companion assembly from NuGet. Installing the assembly can easily be achieved by using the package manager. This assembly contains all the required logic to handle and respond to incoming requests.

📘

The assembly can also be used to use any of Venly's APIs completely server-side.

Venly Microservice

Now we can replace the initial microservice template code with our logic. This means,

  • Deriving from VenlyMicroservice instead of Microservice.
  • Calling the appropriate functions to handle our incoming requests.
  • Make sure the input parameter and return type are both string
  • Optional, configuring the Endpoint Guard (system that allows you to configure access to certain endpoints)
using System.Threading.Tasks;
using Beamable.Server;
using Venly;
using Venly.Companion;

namespace Beamable.VenlyProviderService
{
	[Microservice("VenlyProviderService")]
	public class VenlyProviderService : VenlyMicroservice
	{
		[ClientCallable]
		public async Task<string> Execute(string request)
		{
                        //(optional) Here you can also configure the Endpoint Guard
                        //Changing the default behavior of what endpoints are allowed/denied
                        VenlyAPI.Backend.AllowEndpoint(VenlyAPI.Wallet.IDs.ExecuteCryptoTokenTransfer);
                        VenlyAPI.Backend.AllowEndpoint(VenlyAPI.Wallet.IDs.ExecuteMultiTokenTransfer);
                        VenlyAPI.Backend.AllowEndpoint(VenlyAPI.Wallet.IDs.ExecuteNativeTokenTransfer);
                        //...
            
                        return await HandleRequest(request);
		}
	}
}

👍

Your Microservice should be ready for compilation. Build and run the app!
The next step is to bind this Microservice to the Venly API.