You've already forked LuckyWorld
Optimize code to unreal style
This commit is contained in:
@ -14,7 +14,6 @@ ALuckyRobotsGameState::ALuckyRobotsGameState()
|
||||
void ALuckyRobotsGameState::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
if (SocketIOClientComponent)
|
||||
{
|
||||
SocketIOClientComponent->Connect(L"http://localhost:3000/");
|
||||
@ -23,33 +22,25 @@ void ALuckyRobotsGameState::BeginPlay()
|
||||
|
||||
void ALuckyRobotsGameState::DoSendMessage(FString SendValue)
|
||||
{
|
||||
if (SocketIOClientComponent)
|
||||
if (SocketIOClientComponent && SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
if (SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
|
||||
SocketIOClientComponent->Emit("message", SIOJsonValue);
|
||||
}
|
||||
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
|
||||
SocketIOClientComponent->Emit(TEXT("message"), SIOJsonValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ALuckyRobotsGameState::DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection)
|
||||
{
|
||||
if (SocketIOClientComponent)
|
||||
if (SocketIOClientComponent && SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
if (SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
SocketIOClientComponent->BindEventToGenericEvent("response");
|
||||
}
|
||||
SocketIOClientComponent->BindEventToGenericEvent(TEXT("response"));
|
||||
}
|
||||
}
|
||||
|
||||
void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData)
|
||||
{
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this);
|
||||
if (LuckyRobotsGameInstance)
|
||||
if (ULuckyRobotsGameInstance* GameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this))
|
||||
{
|
||||
LuckyRobotsGameInstance->DoGetDispatch(EventName, EventData);
|
||||
GameInstance->DoGetDispatch(EventName, EventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user