Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- #pragma once
- #include "CoreMinimal.h"
- #include "Blueprint/UserWidget.h"
- #include "Interfaces/OnlineIdentityInterface.h"
- #include "Interfaces/OnlineSessionInterface.h"
- #include "EosHandler.generated.h"
- class IOnlineSubsystem;
- /**
- *
- */
- UCLASS()
- class EOS_OSS_TUTORIAL_API UEosHandler : public UUserWidget
- {
- GENERATED_BODY()
- public:
- static void PrintToScreen(const FString& Message, const FColor& Color = FColor::Red, const float Duration = 5.f)
- {
- UE_LOG(LogTemp, Error, TEXT("%s"), *Message);
- if(GEngine)
- GEngine->AddOnScreenDebugMessage(-1, Duration, Color, Message);
- }
- protected:
- UFUNCTION(BlueprintCallable)
- void Login() const;
- UFUNCTION(BlueprintCallable)
- void FindSessions(FName SearchKey, const FString& SearchValue);
- UFUNCTION(BlueprintCallable)
- void CreateLobby(FName KeyName = "KeyName", FString KeyValue = "KeyValue");
- private:
- IOnlineSubsystem* Subsystem;
- TWeakPtr<IOnlineIdentity> Identity;
- TWeakPtr<IOnlineSession> Session;
- FDelegateHandle LoginDelegateHandle, FindSessionsDelegateHandle, CreateLobbyDelegateHandle, JoinSessionDelegateHandle;
- FString ConnectString;
- UPROPERTY(EditAnywhere)
- FName LobbyName = "LobbyName";
- UPROPERTY(EditAnywhere)
- FString Map = "Game/Content/ThirdPerson/Maps/ThirdPersonMap?listen";
- FOnlineSessionSearchResult* SessionToJoin;
- void HandleLoginCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error);
- void HandleFindSessionsCompleted(const bool bWasSuccessful, TSharedRef<FOnlineSessionSearch> Search);
- void HandleCreateLobbyCompleted(FName EosLobbyName, bool bWasSuccessful);
- void JoinSession();
- void HandleJoinSessionCompleted(FName SessionName, EOnJoinSessionCompleteResult::Type Result);
- };
Advertisement
Add Comment
Please, Sign In to add comment