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
.
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
}
- CreateApp - Create a new application.
- DeleteApp - Delete an application using
appId
. Your organization will lose access to this application. - GetAppInfo - Get details for an application using
appId
. - GetApps - Returns an unsorted list of your organization’s applications. An application is uniquely identified by an
appId
. - UpdateApp - Update data for an existing application using
appId
.
- 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.
- CreateBuild - Creates a new build. Responds with a
buildId
that you must pass toRunBuild()
to build the game server artifact. You can optionally pass in abuildTag
to associate an external version with a build. - DeleteBuild - Delete a build. All associated metadata is deleted.
- GetBuildInfo - Get details for a build.
- GetBuilds - Returns an array of builds for an application.
- RunBuild - Builds a game server artifact from a tarball you provide. Pass in the
buildId
generated fromCreateBuild()
.
- CreateDeployment - Create a new deployment. Creating a new deployment means all new rooms created will use the latest deployment configuration, but existing games in progress will not be affected.
- GetDeploymentInfo - Get details for a deployment.
- GetDeployments - Returns an array of deployments for an application.
- 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.
CreatePrivateLobbyDeprecated-⚠️ DeprecatedCreatePublicLobbyDeprecated-⚠️ DeprecatedListActivePublicLobbiesDeprecated-⚠️ Deprecated
- CreateLobby - Create a new lobby for an existing application using
appId
. CreateLocalLobby-⚠️ DeprecatedCreatePrivateLobby-⚠️ DeprecatedCreatePublicLobby-⚠️ Deprecated- GetLobbyInfo - Get details for an existing lobby using
appId
androomId
. - ListActivePublicLobbies - Get all active lobbies for a given application using
appId
. Filter the array by optionally passing in aregion
. - SetLobbyState - Set the state of a lobby using
appId
androomId
. State is intended to be set by the server and must be smaller than 1MB.
GetLogsForApp- Returns a stream of logs for an application usingappId
.⚠️ DeprecatedGetLogsForDeployment- Returns a stream of logs for a deployment usingappId
anddeploymentId
.⚠️ Deprecated- GetLogsForProcess - Returns a stream of logs for a process using
appId
andprocessId
.
- GetMetrics - Get metrics for a process using
appId
andprocessId
.
- GetProcessInfo - Get details for an existing process using
appId
andprocessId
. - GetRunningProcesses - Returns an array of active process objects for an existing application using
appId
. Filter the array by optionally passing in a region. - GetStoppedProcesses - Returns an array of stopped process objects for an existing application using
appId
. Filter the array by optionally passing in a region.
CreateRoomDeprecated-⚠️ DeprecatedDestroyRoomDeprecated-⚠️ DeprecatedGetActiveRoomsForProcessDeprecated-⚠️ DeprecatedGetConnectionInfoDeprecated-⚠️ DeprecatedGetInactiveRoomsForProcessDeprecated-⚠️ DeprecatedGetRoomInfoDeprecated-⚠️ DeprecatedSuspendRoomDeprecated-⚠️ Deprecated
- CreateRoom - Create a new room for an existing application. Poll the
GetConnectionInfo()
endpoint to get connection details for an active room. - DestroyRoom - Destroy a room. All associated metadata is deleted.
- GetActiveRoomsForProcess - Get all active rooms for a given process.
- GetConnectionInfo - Poll this endpoint to get connection details to a room. Clients can call this endpoint without authentication.
- GetInactiveRoomsForProcess - Get all inactive rooms for a given process.
- GetRoomInfo - Retreive current and historical allocation data for a room.
- SuspendRoom - Suspend a room. The room is unallocated from the process but can be rescheduled later using the same
roomId
.
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.
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!