Skip to main content

Create a Session

Last updated on

Call the CreateGameSession() function to create a new session. Make sure you specify the EAccelByteSessionType parameter as dedicated if you want to create a Dedicated Server session, or p2p to create a P2P session.

EAccelByteSessionType SessionType {EAccelByteSessionType::dedicated};
FString GameMode {"TestGameMode"};
FString MapName {"TestMapName"};
FString Version {"1.0.0"};
int32 BotCount {0};
int32 MaxPlayer {10};
int32 MaxSpectator {5};
FString Password {""};
TSharedPtr<FJsonObject> OtherSetting {MakeShared<FJsonObject>()};
OtherSetting->SetStringField("customfield1", "customvalue1");

ApiClient->SessionBrowser.CreateGameSession(SessionType, GameMode, MapName, Version, BotCount, MaxPlayer, MaxSpectator, Password, OtherSetting,
THandler<FAccelByteModelsSessionBrowserData>::CreateLambda([](const FAccelByteModelsSessionBrowserData& Result)
{
// Do something when request success
}), FErrorHandler::CreateLambda([](const int32 Code, const FString& Msg)
{
// Do something when request error
}));