How can i set DD server name?
// Fill out your copyright notice in the Description page of Project Settings.
#include <iostream>
#include <fstream>
#include <string>
#include "DedicatedGameSession.h"
#include "OnlineSubsystem.h"
#include "OnlineSessionInterface.h"
#include "OnlineSessionSettings.h"
void ADedicatedGameSession::RegisterServer()
{
Super::RegisterServer();
int Players = 100;
bool isLan = false;
std::fstream f("ServerDefault.ini");
std::string s;
std::string ServerName;
while (f >> s)
{
if (s == "LAN")
{
f >> s;
f >> s;
if (s == "true" || s == "True")
{
isLan = true;
}
UE_LOG(LogTemp, Log, TEXT("----Readed Lan Options----"));
}
if (s == "ServerName")
{
f >> s;
f >> ServerName;
UE_LOG(LogTemp, Log, TEXT("----Readed Server Name----"));
}
if (s == "PlayerCount")
{
f >> s;
f >> Players;
UE_LOG(LogTemp, Log, TEXT("----Readed Players Count----"));
}
}
UE_LOG(LogTemp, Log, TEXT("----Start Creating Server----"));
IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
if (OnlineSubsystem == nullptr)
{
UE_LOG(LogTemp, Error, TEXT("----Can't find subsystem----"));
return;
}
UE_LOG(LogTemp, Log, TEXT("----Getting Subsystem----"));
IOnlineSessionPtr Session = OnlineSubsystem->GetSessionInterface();
UE_LOG(LogTemp, Log, TEXT("----Getting Session Interface----"));
FOnlineSessionSettings Settings;
Settings.bIsDedicated = true;
Settings.bIsLANMatch = isLan;
Settings.bAllowJoinInProgress = true;
Settings.bShouldAdvertise = true;
Settings.NumPublicConnections = Players;
Settings.bUsesPresence = true;
UE_LOG(LogTemp, Log, TEXT("----Creating Settings----"));
Session->CreateSession(0,GameSessionName,Settings);
UE_LOG(LogTemp,Log,TEXT("----Session Created----"));
}