UJavascriptWebSocket* UJavascriptWebSocket::Connect(const FString& EndpointString)
{
	FIPv4Endpoint Endpoint;

	if (!FIPv4Endpoint::Parse(EndpointString, Endpoint))
	{
		return nullptr;
	}
	
	auto addr = Endpoint.ToInternetAddr();
	return CreateFrom(new FJavascriptWebSocket(*addr), GetTransientPackage());
}
FUdpMessageBeacon::FUdpMessageBeacon(FSocket* InSocket, const FGuid& InSocketId, const FIPv4Endpoint& InMulticastEndpoint)
	: LastEndpointCount(1)
	, LastHelloSent(FDateTime::MinValue())
	, NextHelloTime(FDateTime::UtcNow())
	, NodeId(InSocketId)
	, Socket(InSocket)
	, Stopping(false)
{
	EndpointLeftEvent = FPlatformProcess::CreateSynchEvent();
	MulticastAddress = InMulticastEndpoint.ToInternetAddr();

	Thread = FRunnableThread::Create(this, TEXT("FUdpMessageBeacon"), 128 * 1024, TPri_AboveNormal, FPlatformAffinity::GetPoolThreadMask());
}
PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS

UJavascriptWebSocket* UJavascriptWebSocket::Connect(const FString& EndpointString)
{
#if WITH_JSWEBSOCKET
	FIPv4Endpoint Endpoint;

	if (!FIPv4Endpoint::Parse(EndpointString, Endpoint))
	{
		return nullptr;
	}
	
	auto addr = Endpoint.ToInternetAddr();
	return CreateFrom(new FJavascriptWebSocket(*addr), GetTransientPackage());
#else
	return nullptr;
#endif
}