How can i set dedicated server name

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----")); 
}

You can use a custom session setting for the server name and search for that when you find your sessions.

Before you call Session->CreateSession(), edit your search settings like so:

FString Name;
Settings.Set(TEXT("CustomServerName"), Name, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing);

This sets a custom session setting with the key “CustomServerName” and it will have its value set to Name which is an FString variable that you can give it whatever content you want.

This adds the session setting “CustomServerName” to your CreateSession() settings param.

To get this value when searching for sessions, use:

FString Name;
SearchResult.Session.SessionSettings.Get(TEXT("CustomServerName"), Name)

In your FindSessions() implementation.

Get()'s 2nd parameter is an out parameter, so after the function call, your variable’s value will be edited to be the value of the “CustomServerName” key.

I Can’t now screen my code, but find session I created in blueprint. How can I create bp node or call function in bp?

Not sure about BPs. I can’t help you with that, sorry.

Ok. Thx I will use your idea tomorrow