// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "Interfaces/OnlineSessionInterface.h" #include "Interfaces/OnlineIdentityInterface.h" #include "OnlineSessionSettings.h" #include "Engine/GameInstance.h" #include "FindSessionsCallbackProxy.h" #include "EosGameInstance.generated.h" USTRUCT(BlueprintType) struct FSearchResultsWrapper { GENERATED_USTRUCT_BODY() public: UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 MaxPlayers; UPROPERTY(EditAnywhere, BlueprintReadWrite) int32 CurrentPlayers; UPROPERTY(EditAnywhere, BlueprintReadWrite) FString Name; FOnlineSessionSearchResult OnlineResult; }; /** * */ UCLASS() class MYPROJECT4_API UEosGameInstance : public UGameInstance { GENERATED_BODY() private: TMap> SessionFoundMap; TSharedPtr UserIdHolder; TSharedPtr SessionSearch; public: UEosGameInstance(const FObjectInitializer& ObjectInitializer); UFUNCTION(BlueprintCallable) void CreateSession(FName SessionName, int32 PlayersCount); /** * Function fired when a session create request has completed * * @param SessionName the name of the session this callback is for * @param bWasSuccessful true if the async action completed without error, false if there was an error */ virtual void OnCreateSessionComplete(FName SessionName, bool bWasSuccessful); /** * Function fired when a session start request has completed * * @param SessionName the name of the session this callback is for * @param bWasSuccessful true if the async action completed without error, false if there was an error */ void OnStartOnlineGameComplete(FName SessionName, bool bWasSuccessful); /*Delegate called when session created*/ FOnCreateSessionCompleteDelegate OnCreateSessionCompleteDelegate; /* Delegate called when session started */ FOnStartSessionCompleteDelegate OnStartSessionCompleteDelegate; /** Delegate for searching for sessions */ FOnFindSessionsCompleteDelegate OnFindSessionsCompleteDelegate; /** Handle to registered delegate for searching a session */ FDelegateHandle OnFindSessionsCompleteDelegateHandle; FOnLoginCompleteDelegate OnLoginCompleteDelegate; void OnFindSessionsComplete(bool bWasSuccessful); FDelegateHandle OnCreateSessionCompleteDelegateHandle; FDelegateHandle OnStartSessionCompleteDelegateHandle; UFUNCTION(BlueprintCallable) void Login(FString Id, FString Token, FString Type); bool bSessionIsGettingCreated = false; void LoginComplete(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error); void FindSessions(TSharedPtr UserId, bool bIsLAN, bool bIsPresence); UFUNCTION(BlueprintImplementableEvent) void FillServerList(const TArray& Results); UFUNCTION(BlueprintCallable) void FindSessionsBP(bool bIsLan); void CheckSharedPtr(); };