Ok, I do not want to use steam for ‘master server’ stuff. So I wrote a little test server that just takes a tcp connection using sockets. On the other end (in UE4) I wanted to make a BP node that allows you to connect to that server (to start with)…
So I have the following code in my project:
#include "BP_MPMENU_FPS_C.h"
#include "MyBlueprintFunctionLibrary.h"
#include "Sockets.h"
#include "Networking.h"
#include "SocketSubsystem.h"
//#include "SharedPointer.h"
UMyBlueprintFunctionLibrary::UMyBlueprintFunctionLibrary(const class FObjectInitializer& PCIP)
: Super(PCIP){}
FString UMyBlueprintFunctionLibrary::RegisterHost()
{
FSocket* Socket = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateSocket(TEXT("default"), TEXT("default"), false);
FString address = TEXT("127.0.0.1");
int32 port = 6666;
FIPv4Address ip;
FIPv4Address::Parse(address, ip);
TSharedRef addr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
addr->SetIp(ip.GetValue());
addr->SetPort(port);
bool connected = Socket->Connect(*addr);
return FString("myBPlibrary is working!");
}
Just as a start to try to use a bp node to run the C++ to create the socket and connect…
Problem is I get “‘TSharedRef’ : use of class template requires template argument list” and other errrors related to TSharedRef not being properly recognized/initialized.
Have searched and find all examples do as my code above (or seem to), so not sure what I am missing. The above code is based on: http://www.osnapgames.com/2014/05/24/connecting-to-a-third-party-socket-server-in-unreal-engine-4/
Any ideas where I have gone wrong or what I am missing? Thanks.