You've already forked LuckyWorld
Rename entire project to LuckyWorldV2, including uproject file, folders and so on
This commit is contained in:
@ -0,0 +1,48 @@
|
||||
// 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"
|
||||
#include "SIOJLibrary.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 && SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
|
||||
SocketIOClientComponent->Emit(TEXT("message"), SIOJsonValue);
|
||||
}
|
||||
}
|
||||
|
||||
void ALuckyRobotsGameState::DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection)
|
||||
{
|
||||
if (SocketIOClientComponent && SocketIOClientComponent->bIsConnected)
|
||||
{
|
||||
SocketIOClientComponent->BindEventToGenericEvent(TEXT("response"));
|
||||
}
|
||||
}
|
||||
|
||||
void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData)
|
||||
{
|
||||
if (ULuckyRobotsGameInstance* GameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this))
|
||||
{
|
||||
GameInstance->OnMessageDispatched.Broadcast(EventName);
|
||||
GameInstance->GetMessageParse(USIOJLibrary::Conv_SIOJsonValueToString(EventData));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user