Skip to main content

.NET (C#) Server SDK Getting Started Guide

Last updated on

Overview

You can use AccelByte Cloud's .NET (C#) SDK to implement our backend services within your game. The SDK acts as a bridge between your game and our services. Follow the tutorials below to learn how to set up our Cloud .NET (C#) SDK.

Prerequisites

Getting Started

Installation

There are two ways of integrating the SDK into your project; you can either clone the repository and then build the solution using dotnet build and AccelByte.Sdk.dll in the bin directory, or, after cloning the repository, you can copy the AccelByte.Sdk_ _directory into your project, add AccelByte.Sdk.csproj into your own solution, and add it as a project reference from your project.

To use the SDK, you will need to set the following environment variables in your system or debug profile (if you are using Visual Studio):

AB_BASE_URL*AccelByte server base URL
AB_CLIENT_ID*OAuth client ID
AB_CLIENT_SECRET*OAuth client secret
AB_APP_NAME*Your app/game name. Keep it unique and short
AB_NAMESPACE*Your namespace ID
AB_TRACEID_VERSIONVersion of Amazon trace ID (default is 1)
AB_ENABLE_TRACEIDEnable sending of Amazon trace ID on every request (default is 1). Set to 0 to disable.
AB_ENABLE_USERAGENTEnable sending user agent string for the default http client (default is 1). Set to 0 to disable.
AB_USERNAMESet the username for accessing AccelByte services
AB_PASSWORDSet the AB_USERNAME password

Using the SDK

  1. Create an AccelByteSDK object.

    using AccelByte.Sdk.Core;

    AccelByteSDK sdk = AccelByteSDK.Builder
    .UseDefaultHttpClient()
    .UseDefaultConfigRepository()
    .UseDefaultTokenRepository()
    .Build();

    The default configuration repository will load the required and optional variables from your environment. If you prefer to create your own repository, you can create a class that implements IConfigRepository and use it with the .SetConfigRepository method while creating the SDK object. You also can enable logging by calling the .EnableLog() method while creating the SDK object.

  2. Log in as a client.

    sdk.LoginClient();

  3. Log in as a player.

    sdk.LoginUser("<username>","<password>");

    If you set .UseDefaultCredentialRepository or .SetCredentialRepository while creating the SDK object, you can omit the parameters for the LoginUser method.

Access AccelByte Services

Once completed, you can use the SDK to access all available AccelByte Cloud services.

SDK Examples

See our .NET (C#) SDK example repo for a selection of test cases you can use to customize your game.

Achievement Service

Before using the Achievement service, you will need to set some permissions. Use the following .NET namespaces:

using AccelByte.Sdk.Api.Achievement.Model;
using AccelByte.Sdk.Api.Achievement.Operation;
using AccelByte.Sdk.Api.Achievement.Wrapper;

Create an achievement

Achievements wAchievements = new Achievements(sdk);

ModelsAchievementRequest newAchievement = new ModelsAchievementRequest()
{
AchievementCode = "achievement-code",
DefaultLanguage = "en",
Name = new Dictionary<string, string>()
{
{"en", "Achievement Name" }
},
Description = new Dictionary<string, string>
{
{"en", "Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit..." }
},
GoalValue = 1000.0,
StatCode = "stat-code",
Hidden = true,
Incremental = false,
LockedIcons = new List<ModelsIcon>()
{
new ModelsIcon()
{
Slug = "shield-locked",
Url = "http://your-image-url"
}
},
UnlockedIcons = new List<ModelsIcon>()
{
new ModelsIcon()
{
Slug = "shield-unlocked",
Url = "http://your-image-url"
}
},
Tags = new List<string>()
};

ModelsAchievementResponse? cResp = wAchievements.AdminCreateNewAchievement(AdminCreateNewAchievement.Builder
.Build(newAchievement, sdk.Namespace));

Retrieve an achievement by its code

    Achievements wAchievements = new Achievements(sdk);

ModelsAchievementResponse? achievement = wAchievements.AdminGetAchievement(AdminGetAchievement.Builder
.Build("<achievement_code>", sdk.Namespace));

Updating an achievement

Achievements wAchievements = new Achievements(sdk);

ModelsAchievementUpdateRequest updateAchievement = new ModelsAchievementUpdateRequest()
{
GoalValue = 2000.0
};

ModelsAchievementResponse? uResp = wAchievements.AdminUpdateAchievement(AdminUpdateAchievement.Builder
.Build(updateAchievement, "<achievement_code>", sdk.Namespace));

Deleting an achievement

Achievements wAchievements = new Achievements(sdk);

wAchievements.AdminDeleteAchievement(AdminDeleteAchievement.Builder
.Build("<achievement_code>", sdk.Namespace));

Retrieving a list of achievements

Achievements wAchievements = new Achievements(sdk);

ModelsPaginatedAchievementResponse? achievementList = wAchievements.AdminListAchievements(AdminListAchievements.Builder
.SetLimit(100)
.SetOffset(0)
.Build(sdk.Namespace));

Basic Service

Before using the Basic service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Basic.Model;
using AccelByte.Sdk.Api.Basic.Operation;
using AccelByte.Sdk.Api.Basic.Wrapper;

Create a player's profile

UserProfile wProfile = new UserProfile(sdk);

UserProfilePrivateCreate createProfile = new UserProfilePrivateCreate()
{
FirstName = "My First Name",
LastName = "My Last Name",
DateOfBirth = DateTime.ParseExact("2000-01-01", "yyyy-MM-dd", CultureInfo.InvariantCulture),
Language = "en"
};

UserProfilePrivateInfo? cInfo = wProfile.CreateMyProfile(
CreateMyProfile.Builder
.SetBody(createProfile)
.Build(sdk.Namespace));

Retrieving a player's profile

UserProfile wProfile = new UserProfile(sdk);

UserProfilePrivateInfo? ownResp = wProfile.GetMyProfileInfo(GetMyProfileInfo.Builder
.Build(sdk.Namespace));

Updating a player's profile

UserProfile wProfile = new UserProfile(sdk);

UserProfilePrivateUpdate updateProfile = new UserProfilePrivateUpdate()
{
TimeZone = "Asia/Jakarta"
};
UserProfilePrivateInfo? updResp = wProfile.UpdateMyProfile(UpdateMyProfile.Builder
.SetBody(updateProfile)
.Build(sdk.Namespace));

Deleting a player's profile

UserProfile wProfile = new UserProfile(sdk);

UserProfilePrivateInfo? delResp = wProfile.DeleteUserProfile(DeleteUserProfile.Builder
.Build(sdk.Namespace, userId));
Assert.IsNotNull(delResp);

Cloud Save Service

Before using the Cloud Save service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Cloudsave.Model;
using AccelByte.Sdk.Api.Cloudsave.Operation;
using AccelByte.Sdk.Api.Cloudsave.Wrapper;

Posting a game record

PublicGameRecord wPublicGameRecord = new PublicGameRecord(_Sdk);

ModelsGameRecordRequestForTest gameRecord = new ModelsGameRecordRequestForTest()
{
Foo = "bar",
FooBar = "foo",
FooValue = 4893
};

wPublicGameRecord.PostGameRecordHandlerV1(PostGameRecordHandlerV1.Builder
.Build(gameRecord, "foo_bar_record", _Sdk.Namespace));

Retrieving a game record

PublicGameRecord wPublicGameRecord = new PublicGameRecord(_Sdk);

ModelsGameRecord? gRecord = wPublicGameRecord.GetGameRecordHandlerV1(GetGameRecordHandlerV1.Builder
.Build("foo_bar_record", _Sdk.Namespace));

Updating a game record

PublicGameRecord wPublicGameRecord = new PublicGameRecord(_Sdk);

ModelsGameRecordRequestForTest updateRecord = new ModelsGameRecordRequestForTest()
{
Foo = "bar",
FooBar = "update",
FooValue = 4893
};

wPublicGameRecord.PutGameRecordHandlerV1(PutGameRecordHandlerV1.Builder
.Build(updateRecord, "foo_bar_record", _Sdk.Namespace));

Deleting a game record

PublicGameRecord wPublicGameRecord = new PublicGameRecord(_Sdk);

wPublicGameRecord.DeleteGameRecordHandlerV1(DeleteGameRecordHandlerV1.Builder
.Build("foo_bar_record", _Sdk.Namespace));

DS Log Manager Service

Before using the DS Log Manager service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Dslogmanager.Model;
using AccelByte.Sdk.Api.Dslogmanager.Operation;
using AccelByte.Sdk.Api.Dslogmanager.Wrapper;

Checking the server logs

TerminatedServers wTerminatedServers = new TerminatedServers(_Sdk);

ModelsLogFileStatus? logs = wTerminatedServers.CheckServerLogs(
CheckServerLogs.Builder
.Build(_Sdk.Namespace, "<your_pod_name>"));

Downloading the server logs

TerminatedServers wTerminatedServers = new TerminatedServers(_Sdk);

wTerminatedServers.DownloadServerLogs(
DownloadServerLogs.Builder
.Build(_Sdk.Namespace, "<your_pod_name>"));

Retrieving a list of terminated servers

TerminatedServers wTerminatedServers = new TerminatedServers(_Sdk);

ModelsListTerminatedServersResponse? tsResp = wTerminatedServers.ListTerminatedServers(ListTerminatedServers.Builder
.SetLimit(10)
.Build(_Sdk.Namespace));
Assert.IsNotNull(tsResp);

DSMC Service

Before using the DSMC service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Dsmc.Model;
using AccelByte.Sdk.Api.Dsmc.Operation;
using AccelByte.Sdk.Api.Dsmc.Wrapper;

Creating a session

Session wSession = new Session(sdk);

ModelsCreateSessionRequest sessionRequest = new ModelsCreateSessionRequest()
{
ClientVersion = "0.3.0",
Configuration = "",
Deployment = "<deployment_name>",
GameMode = "<game_mode>",
MatchingAllies = new List<ModelsRequestMatchingAlly>()
{
new ModelsRequestMatchingAlly()
{
MatchingParties = new List<ModelsRequestMatchParty>()
{
new ModelsRequestMatchParty()
{
PartyAttributes = new Dictionary<string, object>(),
PartyId = "<party_id>",
PartyMembers = new List<ModelsRequestMatchMember>()
{
new ModelsRequestMatchMember()
{
UserId = "<user_id>"
}
}
}
}
}
},
Region = "",
PodName = "",
SessionId = "<session_id>",
Namespace = sdk.Namespace,
};

ModelsSessionResponse? csResp = wSession.CreateSession(CreateSession.Builder
.Build(sessionRequest, sdk.Namespace));

Retrieving a session

Session wSession = new Session(sdk);

csResp = wSession.GetSession(GetSession.Builder
.Build(sdk.Namespace, "<session_id>"));
Assert.IsNotNull(csResp);

Claiming a server for a session

Session wSession = new Session(sdk);

ModelsClaimSessionRequest claimServer = new ModelsClaimSessionRequest()
{
SessionId = "<session_id>"
};
wSession.ClaimServer(ClaimServer.Builder.Build(claimServer, sdk.Namespace));

Event Log Service

Before using the Event Log service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Eventlog.Model;
using AccelByte.Sdk.Api.Eventlog.Operation;
using AccelByte.Sdk.Api.Eventlog.Wrapper;

Retrieving a set of events

EventV2 wEvent = new EventV2(sdk);

ModelsGenericQueryPayload eQueryPayload = new ModelsGenericQueryPayload()
{
ClientId = sdk.Configuration.ConfigRepository.ClientId
};

ModelsEventResponseV2? eResp = wEvent.QueryEventStreamHandler(QueryEventStreamHandler.Builder
.SetOffset(0)
.SetPageSize(10)
.Build(eQueryPayload, sdk.Namespace));

Retrieving player events

EventV2 wEvent = new EventV2(sdk);

eResp = wEvent.GetEventSpecificUserV2Handler(GetEventSpecificUserV2Handler.Builder
.SetOffset(0)
.SetPageSize(10)
.Build(sdk.Namespace, "<user_id>");

GDPR Service

Before using the GDPR service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Gdpr.Model;
using AccelByte.Sdk.Api.Gdpr.Operation;
using AccelByte.Sdk.Api.Gdpr.Wrapper;

Submitting a request for a player account deletion

DataDeletion wGdprDeletion = new DataDeletion(_Sdk);

ModelsRequestDeleteResponse? delResp = wGdprDeletion.AdminSubmitUserAccountDeletionRequest(
AdminSubmitUserAccountDeletionRequest.Builder
.Build(sdk.Namespace, "<user_id>"));

Retrieving player personal data requests from a player

DataRetrieval wGdprRetrieval = new DataRetrieval(sdk);

ModelsUserPersonalDataResponse? reqResp = wGdprRetrieval.AdminGetUserPersonalDataRequests(
AdminGetUserPersonalDataRequests.Builder
.SetLimit(10)
.SetOffset(0)
.Build(_Sdk.Namespace, "<user_id>"));

Creating an admin email configuration

DataRetrieval wGdprRetrieval = new DataRetrieval(sdk);

wGdprRetrieval.SaveAdminEmailConfiguration(
SaveAdminEmailConfiguration.Builder
.Build(new List<string>
{
"dummy@example.com"
}, sdk.Namespace));

List<string>? emails = wGdprRetrieval.GetAdminEmailConfiguration(
GetAdminEmailConfiguration.Builder
.Build(sdk.Namespace));

Updating an admin email configuration

DataRetrieval wGdprRetrieval = new DataRetrieval(sdk);

wGdprRetrieval.UpdateAdminEmailConfiguration(
UpdateAdminEmailConfiguration.Builder
.Build(new List<string>() { "anotheremail@dummy.com" }, sdk.Namespace));

Deleting an admin email configuration

DataRetrieval wGdprRetrieval = new DataRetrieval(sdk);

wGdprRetrieval.DeleteAdminEmailConfiguration(Api.Gdpr.Operation.DeleteAdminEmailConfiguration.Builder
.Build(sdk.Namespace, new List<string>() { "anotheremail@dummy.com" }));

Group Service

Before using the Group service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Group.Model;
using AccelByte.Sdk.Api.Group.Operation;
using AccelByte.Sdk.Api.Group.Wrapper;

Creating a group

Group wGroup = new Group(sdk);

ModelsPublicCreateNewGroupRequestV1 createGroup = new ModelsPublicCreateNewGroupRequestV1()
{
GroupName = "Name of the Group",
GroupType = "PUBLIC",
GroupDescription = "Group's description",
GroupMaxMember = 100,
GroupRegion = "us",
ConfigurationCode = "<group_configuration_code>"
};

ModelsGroupResponseV1? cGroup = wGroup.CreateNewGroupPublicV1(
CreateNewGroupPublicV1.Builder
.Build(createGroup, sdk.Namespace));

Retrieving a group

Group wGroup = new Group(sdk);

ModelsGroupResponseV1? gGroup = wGroup.GetSingleGroupPublicV1(
GetSingleGroupPublicV1.Builder
.Build("<group_id>", sdk.Namespace));

Updating a group

Group wGroup = new Group(sdk);

ModelsUpdateGroupRequestV1 updateGroup = new ModelsUpdateGroupRequestV1()
{
GroupDescription = "Updated description."
};

ModelsGroupResponseV1? uGroup = wGroup.UpdateSingleGroupV1(
UpdateSingleGroupV1.Builder
.Build(updateGroup, "<group_id>", sdk.Namespace));

Deleting a group

Group wGroup = new Group(sdk);

wGroup.DeleteGroupPublicV1(
DeleteGroupPublicV1.Builder
.Build("<group_id>", sdk.Namespace));

IAM Service

Before using the IAM service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Iam.Model;
using AccelByte.Sdk.Api.Iam.Operation;
using AccelByte.Sdk.Api.Iam.Wrapper;

Creating a player

UsersV4 wIamUserV4 = new UsersV4(sdk);

AccountCreateUserRequestV4 newUser = new AccountCreateUserRequestV4()
{
AuthType = "EMAILPASSWD",
EmailAddress = "<user_email>",
Password = "<user_password>",
DisplayName = "User Display Name",
Username = "<user_name>",
Country = "ID",
DateOfBirth = "1995-01-10"
};

AccountCreateUserResponseV4? cuResp = wIamUserV4.PublicCreateUserV4(
PublicCreateUserV4.Builder
.Build(newUser, sdk.Namespace));

Retrieving a player

Users wIamUser = new Users(sdk);

ModelUserResponse? gUser = wIamUser.GetUserByUserID(
GetUserByUserID.Builder
.Build(sdk.Namespace, "<user_id>"));

Updating a player

Users wIamUser = new Users(sdk);

ModelUserUpdateRequest updateUser = new ModelUserUpdateRequest()
{
DateOfBirth = "1996-01-10"
};

ModelUserResponse? uuResp = wIamUser.UpdateUser(
UpdateUser.Builder
.Build(updateUser, sdk.Namespace, "<user_id>"));

Deleting a player

Users wIamUser = new Users(sdk);
wIamUser.DeleteUser(
DeleteUser.Builder
.Build(sdk.Namespace, "<user_id>"));

Leaderboard Service

Before using the Leaderboard service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Leaderboard.Model;
using AccelByte.Sdk.Api.Leaderboard.Operation;
using AccelByte.Sdk.Api.Leaderboard.Wrapper;

Creating a leaderboard

LeaderboardConfiguration wLeaderboard = new LeaderboardConfiguration(sdk);

ModelsLeaderboardConfigReq newLeaderboard = new ModelsLeaderboardConfigReq()
{
LeaderboardCode = "<leaderboard_code>",
Name = "<leaderboard_name>",
StatCode = "1",
SeasonPeriod = 36,
Descending = false,
StartTime = DateTime.Now.AddMonths(1).ToString("yyyy-MM-dd'T'HH:mm:ss.ffK");,
Daily = new ModelsDailyConfig()
{
ResetTime = "00:00:00"
},
Weekly = new ModelsWeeklyConfig()
{
ResetDay = 0,
ResetTime = "00:00:00"
},
Monthly = new ModelsMonthlyConfig()
{
ResetDate = 1,
ResetTime = "00:00:00"
}
};

ModelsLeaderboardConfigReq? cLeaderboard = wLeaderboard.CreateLeaderboardConfigurationAdminV1(
CreateLeaderboardConfigurationAdminV1.Builder
.Build(newLeaderboard, sdk.Namespace));

Retrieving a leaderboard

LeaderboardConfiguration wLeaderboard = new LeaderboardConfiguration(sdk);

ModelsGetLeaderboardConfigResp? gLeaderboard = wLeaderboard.GetLeaderboardConfigurationAdminV1(
GetLeaderboardConfigurationAdminV1.Builder
.Build("<leaderboard_code>", sdk.Namespace));

Updating a leaderboard

LeaderboardConfiguration wLeaderboard = new LeaderboardConfiguration(sdk);

ModelsUpdateLeaderboardConfigReq updateLeaderboard = new ModelsUpdateLeaderboardConfigReq()
{
Name = "CSharp SDK Leaderboard Test",
StatCode = "1",
StartTime = start_time,
SeasonPeriod = 40
};

ModelsGetLeaderboardConfigResp? uLeaderboard = wLeaderboard.UpdateLeaderboardConfigurationAdminV1(
UpdateLeaderboardConfigurationAdminV1.Builder
.Build(updateLeaderboard, "<leaderboard_code>", sdk.Namespace));

Deleting a leaderboard

LeaderboardConfiguration wLeaderboard = new LeaderboardConfiguration(sdk);

wLeaderboard.DeleteLeaderboardConfigurationAdminV1(
DeleteLeaderboardConfigurationAdminV1.Builder
.Build("<leaderboard_code>", sdk.Namespace));

Before using the Legal service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Legal.Model;
using AccelByte.Sdk.Api.Legal.Operation;
using AccelByte.Sdk.Api.Legal.Wrapper;

Accepting multiple policies

Agreement wLegalAgreement = new Agreement(sdk);

List<AcceptAgreementRequest> policies = new List<AcceptAgreementRequest>();
policies.Add(new AcceptAgreementRequest()
{
PolicyId = "<policy_id>",
PolicyVersionId = "<version_id>",
LocalizedPolicyVersionId = "<localized_id>",
IsAccepted = true
});

AcceptAgreementResponse? resp = wLegalAgreement.BulkAcceptVersionedPolicy(
BulkAcceptVersionedPolicy.Builder
.SetBody(policies)
.Build());

Retrieving agreements

Agreement wLegalAgreement = new Agreement(sdk);

List<RetrieveAcceptedAgreementResponse>? aggrs = wLegalAgreement.RetrieveAgreementsPublic(
RetrieveAgreementsPublic
.Builder.Build());
Agreement wLegalAgreement = new Agreement(sdk);

List<AcceptAgreementRequest> aggreementRequests = new List<AcceptAgreementRequest>()
{
new AcceptAgreementRequest()
{
LocalizedPolicyVersionId = targetLocalizedPolicyId,
PolicyVersionId = targetPolicyVersionId,
PolicyId = targetPolicyId,
IsAccepted = true
}
};

wLegalAgreement.ChangePreferenceConsent(
ChangePreferenceConsent.Builder
.SetBody(aggreementRequests)
.Build());

Lobby Service

Before using the Lobby service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Lobby.Model;
using AccelByte.Sdk.Api.Lobby.Operation;
using AccelByte.Sdk.Api.Lobby.Wrapper;

Sending free form notifications to all players

Notification wLobbyNotification = new Notification(sdk);

ModelFreeFormNotificationRequest notifBody = new ModelFreeFormNotificationRequest()
{
Topic = "csharpsdk_test",
Message = "This is integration test for CSharp Server SDK."
};

wLobbyNotification.FreeFormNotification(FreeFormNotification.Builder
.Build(notifBody, sdk.Namespace));

Matchmaking Service

Before using the Matchmaking service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Matchmaking.Model;
using AccelByte.Sdk.Api.Matchmaking.Operation;
using AccelByte.Sdk.Api.Matchmaking.Wrapper;

Creating a channel

Matchmaking wMatchmaking = new Matchmaking(sdk);

ModelsChannelRequest channelReq = new ModelsChannelRequest()
{
Deployment = "<deployment_name>",
Description = "<channel_description>",
FindMatchTimeoutSeconds = 3600,
GameMode = "<channel_name>",
Joinable = false,
MaxDelayMs = 0,
SessionQueueTimeoutSeconds = 0,
SocialMatchmaking = false,
UseSubGamemode = false,
RuleSet = new ModelsRuleSet()
{
Alliance = new ModelsAllianceRule()
{
MaxNumber = 2,
MinNumber = 2,
PlayerMaxNumber = 1,
PlayerMinNumber = 1
},
AllianceFlexingRule = new List<ModelsAllianceFlexingRule>(),
FlexingRule = new List<ModelsFlexingRule>(),
MatchOptions = new ModelsMatchOptionRule()
{
Options = new List<ModelsMatchOption>()
},
MatchingRule = new List<ModelsMatchingRule>(),
SubGameModes = new Dictionary<string, ModelsSubGameMode>()
}
};

ModelsCreateChannelResponse? cResp = wMatchmaking.CreateChannelHandler(CreateChannelHandler.Builder
.Build(channelReq, sdk.Namespace));

Retrieving a channel

Matchmaking wMatchmaking = new Matchmaking(sdk);

ModelsChannelV1? gResp = wMatchmaking.GetSingleMatchmakingChannel(GetSingleMatchmakingChannel.Builder
.Build("<channel_name>", sdk.Namespace));

Retrieving sessions in a channel

Matchmaking wMatchmaking = new Matchmaking(sdk);

List<ModelsMatchmakingResult>? mResults = wMatchmaking.GetAllSessionsInChannel(GetAllSessionsInChannel.Builder
.Build("<channel_name>", sdk.Namespace));

Updating a channel

Matchmaking wMatchmaking = new Matchmaking(sdk);

ModelsUpdateChannelRequest updateChannel = new ModelsUpdateChannelRequest()
{
Description = "Updated description."
};

wMatchmaking.UpdateMatchmakingChannel(UpdateMatchmakingChannel.Builder
.Build(updateChannel, "<channel_name>", sdk.Namespace));

Deleting a channel

Matchmaking wMatchmaking = new Matchmaking(sdk);

wMatchmaking.DeleteChannelHandler(DeleteChannelHandler.Builder
.Build("<channel_name>", sdk.Namespace));

Platform Service

Before using the Platform service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Platform.Model;
using AccelByte.Sdk.Api.Platform.Operation;
using AccelByte.Sdk.Api.Platform.Wrapper;

Creating a store

Store wStore = new Store(sdk);

StoreCreate createStore = new StoreCreate()
{
Title = "Lorem Ipsum",
Description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
DefaultLanguage = "en",
DefaultRegion = "US",
SupportedLanguages = new List<string>() { "en", "id" },
SupportedRegions = new List<string>() { "US", "ID" }
};

StoreInfo? cStore = wStore.CreateStore(CreateStore.Builder
.SetBody(createStore)
.Build(sdk.Namespace));

Retrieving a store

Store wStore = new Store(sdk);

StoreInfo? gStore = wStore.GetStore(GetStore.Builder
.Build(sdk.Namespace, "<store_id>"));

Updating a store

Store wStore = new Store(sdk);

StoreUpdate updateStore = new StoreUpdate()
{
Description = "Updated description."
};
StoreInfo? cStoreUpdate = wStore.UpdateStore(UpdateStore.Builder
.SetBody(updateStore)
.Build(sdk.Namespace, "<store_id>"));

Deleting a store

Store wStore = new Store(sdk);

StoreInfo? dStore = wStore.DeleteStore(DeleteStore.Builder
.Build(sdk.Namespace, "<store_id>"));

Session Browser Service

Before using the Session Browser service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Sessionbrowser.Model;
using AccelByte.Sdk.Api.Sessionbrowser.Operation;
using AccelByte.Sdk.Api.Sessionbrowser.Wrapper;

Creating a session

Session wSBSession = new Session(sdk);

ModelsCreateSessionRequest createSession = new ModelsCreateSessionRequest()
{
SessionType = "p2p",
GameVersion = "0.3.0",
Namespace = sdk.Namespace,
Username = "<user_name>",
GameSessionSetting = new ModelsGameSessionSetting()
{
Mode = "<mode>",
AllowJoinInProgress = true,
MapName = "<map_name>",
MaxPlayer = 100
}
};

ModelsSessionResponse? cResp = wSBSession.CreateSession(
CreateSession.Builder
.Build(createSession, sdk.Namespace));

Retrieving a session

Session wSBSession = new Session(sdk);

ModelsSessionResponse? gResp = wSBSession.GetSession(
GetSession.Builder
.Build(sdk.Namespace, "<session_id>"));

Updating a session

Session wSBSession = new Session(sdk);

ModelsUpdateSessionRequest updateSession = new ModelsUpdateSessionRequest()
{
GameMaxPlayer = 150
};
ModelsSessionResponse? uResp = wSBSession.UpdateSession(
UpdateSession.Builder
.Build(updateSession, sdk.Namespace, "<session_id>"));

Deleting a session

Session wSBSession = new Session(sdk);

ModelsSessionResponse? dResp = wSBSession.DeleteSession(
DeleteSession.Builder
.Build(sdk.Namespace, "<session_id>"));

Social Service

Before using the Social service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Social.Model;
using AccelByte.Sdk.Api.Social.Operation;
using AccelByte.Sdk.Api.Social.Wrapper;

Creating a statistic

StatConfiguration wStatConfig = new StatConfiguration(sdk);

Api.Social.Model.StatCreate createStat = new Api.Social.Model.StatCreate()
{
Name = "<stat_name>",
Description = "<stat_description>",
StatCode = stat_code,
SetBy = "SERVER",
Minimum = 0.0,
Maximum = 100.0,
DefaultValue = 50.0,
IncrementOnly = true,
SetAsGlobal = false,
Tags = new List<string>()
};

StatInfo? cStat = wStatConfig.CreateStat(
CreateStat.Builder
.SetBody(createStat)
.Build(sdk.Namespace));

Retrieving a statistic

StatConfiguration wStatConfig = new StatConfiguration(sdk);

StatInfo? gStat = wStatConfig.GetStat(
GetStat.Builder
.Build(sdk.Namespace, "<stat_code>"));

Updating a statistic

StatConfiguration wStatConfig = new StatConfiguration(sdk);

StatUpdate updateStat = new StatUpdate()
{
Description = "Updated description."
};

StatInfo? uStat = wStatConfig.UpdateStat(
UpdateStat.Builder
.SetBody(updateStat)
.Build(sdk.Namespace, "<stat_code>"));

Deleting a statistic

StatConfiguration wStatConfig = new StatConfiguration(sdk);

wStatConfig.DeleteStat(
DeleteStat.Builder
.Build(sdk.Namespace, "<stat_code>"));

Retrieving all statistics

StatConfiguration wStatConfig = new StatConfiguration(sdk);

StatPagingSlicedResult? result = wStatConfig.GetStats(
GetStats.Builder
.SetLimit(10)
.SetOffset(0)
.Build(_Sdk.Namespace));

Querying statistics by a keyword

StatConfiguration wStatConfig = new StatConfiguration(sdk);

StatPagingSlicedResult? result = wStatConfig.QueryStats(
QueryStats.Builder
.SetLimit(10)
.SetOffset(0)
.Build(_Sdk.Namespace, "<keyword>"));

UGC Service

Before using the UGC service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Ugc.Model;
using AccelByte.Sdk.Api.Ugc.Operation;
using AccelByte.Sdk.Api.Ugc.Wrapper;

Creating a tag

AdminTag wAdminTag = new AdminTag(sdk);

ModelsCreateTagRequest createTag = new ModelsCreateTagRequest()
{
Tag = "<tag_name>"
};
ModelsCreateTagResponse? cTag = wAdminTag.AdminCreateTag(
AdminCreateTag.Builder
.Build(createTag, sdk.Namespace));

Retrieving a list of tags

AdminTag wAdminTag = new AdminTag(sdk);

ModelsPaginatedGetTagResponse? gTag = wAdminTag.AdminGetTag(
AdminGetTag.Builder
.SetOffset("0")
.SetLimit("10")
.Build(sdk.Namespace));

Updating a tag

AdminTag wAdminTag = new AdminTag(sdk);

ModelsCreateTagRequest updateTag = new ModelsCreateTagRequest()
{
Tag = "<tag_name>"
};
ModelsCreateTagResponse? uTag = wAdminTag.AdminUpdateTag(
AdminUpdateTag.Builder
.Build(updateTag, sdk.Namespace, "<tag_id>"));

Deleting a tag

AdminTag wAdminTag = new AdminTag(sdk);

wAdminTag.AdminDeleteTag(
AdminDeleteTag.Builder
.Build(sdk.Namespace, "<tag_id>"));

Lobby WebSocket Service

Use following .NET namespaces:

    using AccelByte.Sdk.Api.Lobby;
using AccelByte.Sdk.Api.Lobby.WSModel;

The Lobby WebSocket service works slightly differently to other AccelByte services. Before using the Lobby WebSocket service, you will need to create a LobbyService object.

LobbyService lobby = new LobbyService(sdk.Configuration);
lobby.OnReceiveError = (eMessage) =>
{
is_error = true;
//handle if error occurs here
};

Once completed, you can connect and listen to the Lobby WebSocket service.

Task connectTask = lobby.Connect(false);
connectTask.Wait();

Task listenTask = Task.Run(() => lobby.Listen());

Sending a create party request message

lobby.OnPartyCreateResponse = (PartyCreateResponse resp) =>
{
is_response_received = true;
//create party response


};

Task sendTask = lobby.SendPartyCreateRequest(new PartyCreateRequest()
{
Id = request_id
}, 0);
sendTask.Wait();

When you are finished, disconnect from the Lobby WebSocket service.

Task disconnectTask = lobby.Disconnect();
disconnectTask.Wait();