Skip to content
This repository has been archived by the owner on Sep 19, 2023. It is now read-only.

speakeasy-sdks/hathora-sdk-unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity SDK

Serverless cloud hosting for multiplayer games

SDK Installation

The SDK can either be compiled using dotnet build and the resultant .dll file can be copied into your Unity project's Assets folder, or you can copy the source code directly into your project.

The SDK relies on Newtonsoft's JSON.NET Package which can be installed via the Unity Package Manager.

To do so open the Package Manager via Window > Package Manager and click the + button then Add package from git URL... and enter com.unity.nuget.newtonsoft-json and click Add.

SDK Example Usage

using Hathora;
using Hathora.Models.Shared;
using Hathora.Models.Operations;

var sdk = new HathoraSDK(
    appId: "app-af469a92-5b45-4565-b3c4-b79878de67d2"
);

using(var res = await sdk.AppV1.CreateAppAsync(new CreateAppSecurity() {
        HathoraDevToken = "",
    }, new AppConfig() {
        AppName = "minecraft",
        AuthConfiguration = new AuthConfiguration() {
            Anonymous = new RecordStringNever() {},
            Google = new AuthConfigurationGoogle() {
                ClientId = "corrupti",
            },
            Nickname = new RecordStringNever() {},
        },
    }))
{
    // handle response
}

Available Resources and Operations

  • LoginAnonymous - Returns a unique player token for an anonymous user.
  • LoginGoogle - Returns a unique player token using a Google-signed OIDC idToken.
  • LoginNickname - Returns a unique player token with a specified nickname for a user.
  • GetPingServiceEndpoints - Returns an array of all regions with a host and port that a client can directly ping. Open a websocket connection to wss://<host>:<port>/ws and send a packet. To calculate ping, measure the time it takes to get an echo packet back.

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release!

SDK Created by Speakeasy