Fix Folder Structure

This commit is contained in:
martinluckyrobots
2025-04-07 10:28:47 +08:00
parent 5931bc7e84
commit 5d8e225db5
22 changed files with 24 additions and 24 deletions

View File

@ -0,0 +1,55 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GameModes/LuckyRobotsGameState.h"
#include "SocketIOClientComponent.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "Core/LuckyRobotsGameInstance.h"
ALuckyRobotsGameState::ALuckyRobotsGameState()
{
SocketIOClientComponent = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("SocketIOClientComponent"));
}
void ALuckyRobotsGameState::BeginPlay()
{
Super::BeginPlay();
if (SocketIOClientComponent)
{
SocketIOClientComponent->Connect(L"http://localhost:3000/");
}
}
void ALuckyRobotsGameState::DoSendMessage(FString SendValue)
{
if (SocketIOClientComponent)
{
if (SocketIOClientComponent->bIsConnected)
{
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
SocketIOClientComponent->Emit("message", SIOJsonValue);
}
}
}
void ALuckyRobotsGameState::DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection)
{
if (SocketIOClientComponent)
{
if (SocketIOClientComponent->bIsConnected)
{
SocketIOClientComponent->BindEventToGenericEvent("response");
}
}
}
void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData)
{
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this);
if (LuckyRobotsGameInstance)
{
LuckyRobotsGameInstance->DoGetDispatch(EventName, EventData);
}
}