Multiplayer Operations

The Multiplayer Operations Developer Hub

Welcome to the Multiplayer Operations developer hub. You'll find comprehensive guides and documentation to help you start working with Multiplayer Operations as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    API Reference

Set up zeuz in Unreal Engine

Getting Started

To use zeuz in Unreal Engine, we created the plugin, which can be downloaded for free in the Unreal Engine Marketplace .

This tutorial will guide you through you set up Unreal Engine, installation of the Zeuzsdk Marketplace Plugin and make your first API call in Unreal, using the plugin.

You can make your first API call using Blueprints, C++, or both.

Unreal Setup and plugin installation

Using the SDK with Blueprint

This is an example to use the Zeuzsdk within Blueprint, it will log in into the backend which is necessary for further API calls.

  1. In the editor toolbar open Blueprints → Open Level Blueprint
  2. Connect to the existing Event Begin Play node the Zeuzsdk → Auth → SimpleAuthLogin.
  3. Enter the username and password from the zeuz control panel
  4. Use the Endpoint: https://zcp.zeuz.io/api/v1
  5. Enter the Proj ID and Env ID which you want to work with from the zeuz control panel

Since the API call is asynchronous the immediate output of the login node will not bear any results, instead these will be delivered by events.

  1. Create a custom event on the On Success pin and attach a Print String to show the now logged in Developer ID
  2. Create a custom event on the On Failure pin and attach a Print String to show the Error

Finally start the blueprint with the play button and the result is shown in the game window.

Using the SDK with C++

Calling this function from C++ is equivalent to the Blueprint version, except the output is printed to to Output instead of the screen.

  1. The Proj ID and Env ID from the zeuz control panel are saved in the default Context
  2. Username and password are entered into the authentication input struct
  3. A callback delegate is bound which will be invoked with the result of the API call
  4. The API function AuthLogin is called.
DEFINE_LOG_CATEGORY_STATIC(LogTest, Log, All);

void TestAuth() {
  FZeuzContext& ctx = FZeuzContext::Def;
  ctx.ProjID = "ovDwSBfgjlXNtBOmQqkSNlFAenS";
  ctx.EnvID = "uOJvpWmhzkVByequrudsOxcExaH";
  
  FZeuzSimpleAuthLoginIn login;
  login.Login = "[email protected]";
  login.Password = "demo";

  UZeuzApiSimpleAuth::FDelegateAuthLogin onresult;
  onresult.BindLambda(
    [](FZeuzContext Context, FString Error) {
      if (!Error.IsEmpty())
      {
        UE_LOG(LogTest, Warning, TEXT("Error: %s"), *Error);
      } else {
        UE_LOG(LogTest, Warning, TEXT("Success: %s"), *Context.DeveloperID);
      }
    }
  );

  UZeuzApiSimpleAuth::AuthLogin(login, onresult, ctx);
}

Using the Online Subsystem

Install the OnlineSubsystemZeuz from the marketplace or https://sdk.zeuz.io/

Add OnlineSubsystem and OnlineSubsystemZeuz to your ProjectName.Build.cs

PublicDependencyModuleNames.AddRange(new string[] { 
  "Core", "CoreUObject", "Engine", "InputCore", 
  "OnlineSubsystem", "OnlineSubsystemZeuz"

Activate the OSS in your Config/DefaultEngine.ini and configure your ProjID and EnvID

[OnlineSubsystem]
DefaultPlatformService=Zeuz

[OnlineSubsystemZeuz]
Endpoint="<<API_ENDPOINT_URL>>"
ProjID="ovDwSBfgjlXNtBOmQqkSNlFAenS"
EnvID="uOJvpWmhzkVByequrudsOxcExaH"

Now you can use the OnlineSubsystem in you project.

#include "OnlineSubsystemZeuz.h"

void FZeuzUtils::AuthLoginProfile(const FString& Username, const FString& Password, const FZeuzRequestResult& RequestResult)
{
    // Store a static map of delegate handles
    static TMap<uint32, FDelegateHandle> DelegateHandles;
    // Use the identity online subsystem for logging in.
    IOnlineIdentityPtr Identity = FZeuzOSSUtils::GetIdentityInterface();
    FOnLoginCompleteDelegate OnResult;
    FOnlineAccountCredentials Credentials;
    Credentials.Id    = Username;
    Credentials.Token = Password;
    // The delegate handle is created after the delegate, so the delegate instead has a reference to where the delegate will be stored.
    uint32 DelegateKey = GetFreshKey(DelegateHandles);
    OnResult.BindLambda([RequestResult, DelegateKey, Identity](int32 LocalUserNum, bool bSuccess, const FUniqueNetId& Id, const FString& Error) {
        if (bSuccess)
        {
            UE_LOG(LogZeuzUtils, Display, TEXT("AuthLoginProfile - Connection success: %s"), *Id.ToString());
            RequestResult.ExecuteIfBound(true);
        }
        else
        {
            UE_LOG(LogZeuzUtils, Error, TEXT("AuthLoginProfile - Error: %s"), *Error);
            RequestResult.ExecuteIfBound(false);
        }
        if (!DelegateHandles.Contains(DelegateKey))
        {
            UE_LOG(LogZeuzUtils, Error, TEXT("Unable to find the OnLoginCompleteDelegateHandle"), *Error);
            return;
        }
        Identity->ClearOnLoginCompleteDelegate_Handle(0, DelegateHandles[DelegateKey]);
        DelegateHandles.Remove(DelegateKey);
    });
    DelegateHandles.Add(DelegateKey, Identity->AddOnLoginCompleteDelegate_Handle(0, OnResult));
    bool bSentRequest = Identity->Login(0, Credentials);
    if (!bSentRequest)
    {
        RequestResult.ExecuteIfBound(false);
    }
}

Notes and explanations

  • A context contains a reference to a Project and Environment also it contains a logged in session.
    In most cases only one context is needed therefore exists the default context FZeuzContext::Def.
    Omitting the context will use the default context
  • Blueprint API functions have additional On Success and On Failure delegates for convenience but Callback is called in both cases
  • The login can be done with a developer login, a user login or an Apikey and its corresponding password
  • A session expires after 24h but the SDK can automatically relogin it

Updated about a month ago


Set up zeuz in Unreal Engine


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.