#include "ESIOClient.h"
#include "ESIONative.h"

TSharedPtr<FESIONative> ESIOClient::NewValidNativePointer(const bool bShouldUseTlsLibraries,
                                                                const bool bShouldSkipCertificateVerification)
{
	TSharedPtr<FESIONative> NewPointer = MakeShareable(new FESIONative(bShouldUseTlsLibraries, bShouldSkipCertificateVerification));
	
	PluginNativePointers.Add(NewPointer);
	
	bHasActiveNativePointers = true;

	return NewPointer;
}

TSharedPtr<FESIONative> ESIOClient::ValidSharedNativePointer(FString SharedId, const bool bShouldUseTlsLibraries,
	const bool bShouldSkipCertificateVerification)
{
	//Found key? return it
	if (SharedNativePointers.Contains(SharedId))
	{
		return SharedNativePointers[SharedId];
	}
	//Otherwise request a new id and return it
	else
	{
		TSharedPtr<FESIONative> NewNativePtr = NewValidNativePointer(bShouldUseTlsLibraries, bShouldSkipCertificateVerification);
		SharedNativePointers.Add(SharedId, NewNativePtr);
		AllSharedPtrs.Add(NewNativePtr);
		return NewNativePtr;
	}
}
